Byteazar the Dragon has N piggy banks. Each piggy bank can either be opened with its corresponding key or smashed. Byteazar has placed the keys inside some of the piggy banks, and he remembers exactly which key is in which piggy bank. He intends to buy a car and needs to gain access to all of the piggy banks, but he wants to destroy as few of them as possible.
Once a piggy bank is open (whether unlocked with its key or smashed), the keys inside it can be taken out and used to open the corresponding piggy banks without smashing them, and this repeats in a chain. Determine the minimum number of piggy banks that must be smashed to gain access to all of them.
Write a program which:
The first line contains a single integer N (1≤N≤106) - the number of piggy banks. The piggy banks (and their corresponding keys) are numbered from 1 to N. Each of the next N lines contains one integer: the i-th of these lines gives the number of the piggy bank in which key i has been placed.
Output a single integer - the minimal number of piggy banks that must be smashed in order to gain access to all of them.
For the sample input, piggy banks 1 and 4 must be smashed. Smashing bank 1 yields key 2, which opens bank 2; bank 2 contains keys 1 and 3, which open banks 1 and 3. Bank 4 holds only its own key, so it must be smashed separately.