# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def maxDepth(self, root: TreeNode) -> int:
if not root:
return 0
ml=1+self.maxDepth(root.left)
mr=1+self.maxDepth(root.right)
return max(ml,mr)