Juke Artem

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

문제

You are given a tree with nn vertices enumerated from 00 to n1n - 1 inclusive. There is a number in each vertex. Numbers are from 00 to n1n - 1 and are all distinct (i.e. they form a permutation). The number xx is in its place if it is in the xx-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 nn (2n1052 \leq n \leq 10^5), the number of vertices of the tree.

The second line contains n1n - 1 integers p_ip\_i (0p_i<i0 \leq p\_i < i). ii-th of them describes an edge between vertices p_ip\_i and ii.

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

출력

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