Prime Tree

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Bobo proposes a multiplication operation on rooted trees.

Let AA and BB be two arbitrary rooted trees. Then T=ABT = A \cdot B is built by making a copy of BB for each vertex xAx \in A and merging the root of this copy with xx (see the following figure for more details). We then call AA and BB factors of TT.

Apparently, we have T1=1T=TT \cdot \mathbf{1} = \mathbf{1} \cdot T = T, where 1\mathbf{1} is the rooted tree with only one vertex. So, 1\mathbf{1} is a factor of every rooted tree, and every rooted tree is a factor of itself. And if a rooted tree TT only has TT and 1\mathbf{1} as his factors, we call TT a prime tree.

Bobo has a rooted tree TT with nn nodes which are conveniently labeled with 1,2,,n1, 2, \dots, n. He wants to factor TT into multiplication of as many prime trees as possible (that is, find an equation T=T_1T_2T_mT = T\_1 \cdot T\_2 \cdots T\_m where T_iT\_i (1im1 \leq i \leq m) are prime trees and mm is maximum).

Note that 1\mathbf{1} is not a prime tree.

입력

The input contains zero or more test cases, and is terminated by end-of-file. For each test case:

The first line contains an integer nn, the number of nodes (2n1062 \leq n \leq 10^6).

The second line contains (n1)(n - 1) integers p_2,p_3,,p_np\_2, p\_3, \dots, p\_n, where p_ip\_i is the parent of the ii-th node (1p_ii11 \leq p\_i \leq i - 1).

It is guaranteed that the sum of all nn does not exceed 10610^6.

출력

For each test case, output an integer denoting the maximum number of prime factors.