You are given a binary tree encoded as a single space-separated level-order array. Values are read top-to-bottom, left-to-right. The literal token null marks a missing child, so a null never has children of its own. An empty tree is encoded as the single token null.
The depth of the tree is the number of nodes on the longest path from the root down to any leaf. An empty tree has depth 0; a tree with only a root has depth 1.
Print that maximum depth.
Input format
A single line containing the level-order tokens separated by single spaces. Each token is either an integer or the literal null. The line may also be exactly null for an empty tree.
Output format
A single integer: the maximum depth in nodes.
Constraints
- The number of real (non-null) nodes is between 0 and 4000.
- Each node value fits in a signed 32-bit integer.
- The input is always a valid level-order serialization (no
nulltoken ever has children listed after it).