The first line contains an integer $n (1 ≤ n ≤ 100 000)$ — the number of figurines.
The following line contains a sequence of $n$ integers $p_1, p_2, ..., p_n (0 ≤ p_k ≤ n)$ describing the initial configuration. The $k$-th integer $p_k$ is $0$ if the figurine $k$ is free, or the parent of figurine $k$ otherwise.
The following line contains a sequence of $n$ integers $q_1, q_2, ..., q_n (0 ≤ q_k ≤ n)$ describing the target configuration in the same format.
You may assume that both configurations are valid: a figurine is always smaller than its parent and no two figurines have the same parent.
Output a single integer — the minimal number of steps.