Identical Trees
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You are give two rooted tree T_1, T_2 with n vertices. For each tree, every vertex has a distinct integer label in [1,n]. You want to change the label of vertices in T_1, and make two trees identical. After Two trees are identical iff
- The labels of their roots are the same.
- For a non-root vertices with label u, the labels of their parent should also be the same.
After the modification, the label of T_1 should also be a permutation of .
You want to minimize the number of vertices whose labels are changed.
The following is an example (The order of children doesn't matter):

输入描述:

The first line contains an integer . Each of the following two lines contains n integers . p_i means the label of the parent of the vertex with label i. If , it's the root of the tree.
It's guaranteed that you can change the label of T_1 to make two trees identical.

输出描述:

Output one integer, the number of vertices whose labels are changed.

示例1

输入

复制
3
0 1 1
3 3 0

输出

复制
2