A fungal network is a binary tree; each node has an integer strain value. A uniform colony is a subtree (a node together with all of its descendants) in which every node has the same strain value. A single leaf is always a uniform colony.
Report the number of uniform colonies in the network.
Input format
Line 1: an integer k, the number of tokens on line 2.
Line 2: k space-separated tokens giving the tree in level order. The first token is the root; each subsequent token is an integer strain or null for a missing child. Children of null nodes are omitted.
Output format
A single integer: the number of uniform colonies.
Constraints
- The tree has between 1 and 2000 nodes (the root is always present).
- Each strain value is between -1000000 and 1000000.