#agc038f. [agc038_f]Two Permutations
[agc038_f]Two Permutations
Problem Statement
Snuke has permutations and of .
Now, he will make new permutations and of , under the following conditions:
- For each (), should be or .
- For each (), should be or .
Let us define the distance of permutations and as the number of indices such that . Find the maximum possible distance of and .
Constraints
- are all different.
- are all different.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible distance of and .
Sample Input 1
4
2 1 3 0
0 2 3 1
Sample Output 1
3
For example, if we make and , the distance will be , which is the maximum result possible.
Sample Input 2
10
0 4 5 3 7 8 2 1 9 6
3 8 5 6 4 0 2 1 7 9
Sample Output 2
8
Sample Input 3
32
22 31 30 29 7 17 16 3 14 9 19 11 2 5 10 1 25 18 15 24 20 0 12 21 27 4 26 28 8 6 23 13
22 3 2 7 17 9 16 4 14 8 19 26 28 5 10 1 25 18 15 13 11 0 12 23 21 20 29 24 27 6 30 31
Sample Output 3
28