

 Task: Doublerow2n soldiers are standing in a doublerow. They have to be rearranged, so that there are no equally tall soldiers in each row  then we shall say, that the soldiers are set up properly. A single operation consists in swapping two soldiers who occupy the same position (but in different rows). Your task is to determine the minimum number of swaps necessary to set the soldiers up properly.
Example:There is a doublerow of 18 soldiers in the figure. Arrows indicate the swaps that rearrange the soldiers in a proper way.
InputIn the first line of the input there is one integer n, 1 <= n <= 50 000. In each of the two rows there are n soldiers standing. In each of the following two lines there are n positive integers separated by single spaces. In the second line there are numbers x_{1}, x_{2},..., x_{n}, 1 <= x_{i} <= 100 000; x_{i} denotes the height of the ith soldier in the first line. In the thrid line there are numbers y_{1}, y_{2},..., y_{n}, 1 <= y <= _{i}100 000; y_{i} denotes the height of the ith soldier in the second line.It is guaranteed that in the instances from the test data it is possible to set up soldiers properly.
OutputIn the first and only line of the standard output one integer should be written  the minimum number of swaps necessary to set up soldiers properly.
Print friendly version 