Problem 2145 --The Max Depth Of A Tree

## 2145: The Max Depth Of A Tree

Time Limit: 1 Sec  Memory Limit: 32 MB
Submit: 27  Solved: 16
[Submit][Status][Web Board][Creator:][下载FPS1元][添加到购物车][下载测试数据1元][172kb]

## Description

In computer science, a tree is a widely used data structure that simulates a hierarchical tree structure with a set of linked nodes. The depth of a node is the number of nodes in the path to its root,excluding the root node and itself.Now given a tree,you should find the node with the max depth,and output this node's depth.

## Input

The first line of the input contains an integer n(n<=10000) which means the number of non-root nodes.We give numbers to the nodes from 0 to n.0 means the root and 1~n means the non-root nodes.Then n lines follow, line i consists of an integer Ai,which means node Ai is the parent node of node i.We ensure that it's a tree.

## Output

You should output one lines with the max depth value.

## Sample Input

5
3
3
0
2
0


## Sample Output

2

[Submit][Status]