You are given two permutations and of length . A permutation is a sequence of length integers from to , in which all the numbers occur exactly once. For example, are permutations, and are not.
There are two types of operations as follow:
Remove the first integer in . Then append any integer at the end of .
Choose an and modify it to any integer.
You have to find the minimum number of operations to make and the same. Be attention, you do not have to keep in a permutation during the process.
输入描述:
The first line contains an integer — the length of and . The second line contains integers . The third line contains integers . It is guaranteed that and are both permutations.
输出描述:
Output the minimum number of operations to make and the same.
For the first example, there is a possible way: 1. Remove the first integer in and append 4, now becomes . 2. modify to , now becomes . 3. modify to , now becomes . So it only takes operations to convert into .