A binary tree of firewall rule priorities is given in level-order form (a single line of space-separated tokens, null marking a missing child; every non-null node contributes exactly two following tokens for its children).
A node is called a summit if its value is greater than or equal to the value of every one of its ancestors (the nodes on the path from the root down to, but not including, that node). The root has no ancestors, so it is always a summit.
Count how many nodes in the tree are summits.
Input format
Line 1: space-separated level-order tokens describing the binary tree (integers and the token null).
Output format
A single integer: the number of summit nodes. If the tree is empty, print 0.
Constraints
- 0 <= number of nodes <= 500
- Each node value is an integer with -1000 <= value <= 1000