|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||0||0||0||0.000%|
Bitian family is just having a family gathering. Family members are numbered with consecutive numbers from $1$ to $n$. Bityslav is the oldest family member and number $1$ was associated to him. Each of the remaining family members has exactly one parent (kinda weird, but let it be).
Such wonderful family gathering needs to be documented well and there needs to be a photo taken. This photo will depict some of family members arranged in a row. However, this year family members are very choosy. Two members agree to stand next to each other if and only if one of them is an ancestor of the second one (not necessarily an immediate one). We say that A is an ancestor of B if and only if A is either a parent of B or a parent of some of B's ancestors}
Bityslav has a hard task now as he would like as many family members on this photo as possible. What is the biggest number of people that can be present on it?
The first line of input contains one integer $n$ ($2 \le n \le 300\,000$) denoting number of Bitian family members. The second line contains $n-1$ integers $p_2, p_3, \ldots, p_n$ ($1 \le p_i \le n$, $p_i \ne i$ for $2 \le i \le n$), where $p_i$ is an index of a parent of $i$-th family member. You can assume that there is no cycle in this genealogical tree, i.e. nobody is an ancestor of himself.
You should output one integer which is the maximum possible number of family members present on a photo with respect to constraints set by family members.
8 5 5 5 1 1 6 7
Following picture denotes genealogical tree of Bitian family. One of the optimal photos can contain members with numbers $7$, $6$, $8$, $1$, $2$, $5$, $3$ in this order. It can be shown it is impossible to have all of them on one photo.