Christmas is coming, and Alessandro has to decorate his living room with a Christmas tree.
He heard that in Pordenone a new tree shop has just opened, so he decided to go there. This shop has a huge tree decorated with balls, one at each branching point (the root is node ). Of course the balls are quite spectacular, and he noticed that the balls come in different colors in total.
The peculiarity of this shop is that you can buy the whole tree, or cut a branch and buy just a subtree! You can make the cut just below a ball, so that you take that ball and the subtree rooted there.
Alessandro doesn't want just a random tree, he wants the nicest. His taste is in fact quite peculiar, he'd like that the amount of balls of each color to be well distributed. Precisely, let's call the number of balls of (one of) the most frequent color in a subtree, he wants to maximize the number of colors with balls each.
Help Alessandro finding where to cut the tree by printing the maximum amount of most-frequent colors he can get.
Input data
The first line contains the only integer , the number of nodes of the tree.
The second line contains integers , the colors of each ball.
The third line contains integers: is the index of the parent of the -th node.
Output data
The output contains a single line with an integer: chosen the optimal subtree, the number of colors with the highest frequency.
Constraints and Clarifications
- ;
- ;
- For tests worth points, the tree is a line.
- For tests worth more points, , .
- For tests worth more points, .
- For tests worth more points, .
Example 1
stdin
8
1 2 0 2 0 0 1 1
0 0 1 1 3 4 4
stdout
3
Explanation
In the first sample case, there are nodes in different colors. The solution is to cut the tree and take the subtree rooted at node . This way we are left with nodes: the most frequent color has balls, and there are colors with that many balls.
Example 2
stdin
5
0 1 1 0 0
0 1 2 3
stdout
2
Explanation
If, for example, we have kept the entire tree, the most frequent color appears with balls, but there are only colors with balls, so this is worse than the aforementioned solution.