IntermediateRating 1300
Tree Height
A rooted tree on nodes 1..n is given by parent[i] for i = 2..n (node 1 is the root). Print the height (edges on the longest root-to-leaf path).
Input
n, then n − 1 parents.
Output
A number.
Sample 1
Input
5 1 1 2 3
Output
2
Sample 2
Input
1
Output
0
Output appears here