SDE Path

Height of a Binary Tree

Easy

Height of a Binary Tree

Compute the maximum depth (height) of a binary tree.

Input format

The first line contains level-order tokens, where N denotes a null node.

Output format

Print the height (number of nodes on the longest root-to-leaf path). An empty tree has height 0.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
N
Expected output
0
Example 2
Input
73
Expected output
1