The Marble Game

0

0 votes
Easy
Problem

Akhil is playing with marbles along with his friend Siddharth. They have some numbers written on the top of them. Akhil arranges the marbles in the increasing order of numbers on the marbles. But Siddharth being a naugthy kid, disrupts the whole setting of marbles. Akhil is upset, and he wants the original sequence back. Help him by writing a program that tells the minimum number of exchanges required to get the original sequence back.

The sequence 2, 4, 1, 3, 5 involves three exchanges- (4, 1), (2, 1),(4, 3) so that the final arrangement looks like 1, 2, 3, 4, 5, which is sorted.

Input

First line of input contains an integer N, the number of marbles.

Second line of input contains numbers written on the top of each marble (space separated)

Output

Count of minimum no. of exchanges required to make  the arrangement sorted.

All the elements are in the range of int

**NOTE - Put "\n" after printing Output

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?