시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB222100.000%

문제

You are given a tree with $n$ vertices enumerated from $0$ to $n - 1$ inclusive. There is a number in each vertex. Numbers are from $0$ to $n - 1$ and are all distinct (i.e. they form a permutation). The number $x$ is in its place if it is in the $x$-th vertex.

You are allowed to swap two numbers at the endpoints of some edge of the tree. This costs you 0 if at least one of those numbers was in its place before the swap and 1 otherwise.

What is the minimum cost you have to pay to put all numbers in their places?

입력

The first line contains a single integer $n$ ($2 \leq n \leq 10^5$), the number of vertices of the tree.

The second line contains $n - 1$ integers $p_i$ ($0 \leq p_i < i$). $i$-th of them describes an edge between vertices $p_i$ and $i$.

The third line contains $n$ integers $a_i$ ($0 \leq a_i < n$). $i$-th of them (in zero based indexing) is equal to the number which is initially in the $i$-th vertex. $a$ is a permutation.             

출력

Print a single integer --- the minimum cost you have to pay.

예제 입력 1

2
0
0 1

예제 출력 1

0

예제 입력 2

2
0
1 0

예제 출력 2

1

예제 입력 3

3
0 0
0 2 1

예제 출력 3

2