"Arrange" is a planetary popular Flash game. In "Arrange" the player is given a permutation of numbers
In order to break the high score list, you need to perform the minimal amount of swaps possible. You can't do that, but you can write a program that does it for you!
Input Specification
The first line of input contains two integers,
The second line of input contains a permutation of number
Note: the test data shall be such that the solution, not necessarily unique, will always exist.
Output Specification
In the first line of input print the minimal number of swaps,
In the next
Sample Input 1
2 1
2 1
1 2
Sample Output 1
1
1
Sample Input 2
3 2
2 1 3
1 3
2 3
Sample Output 2
3
2
1
2
Sample Input 3
5 5
1 2 3 4 5
1 5
2 5
1 4
1 1
3 5
Sample Output 3
0
Comments