|
|||||||
| Task: skaPiggy banks
Alternative formats: PostScript | PDF Byteazar the Dragon has N piggy banks. Each piggy bank can either be opened with its corresponding key or smashed. Byteazar has put the keys in some of the piggy banks - he remembers which key has been placed in which piggy bank. Byteazar intends to buy a car and needs to gain access to all of the piggy banks. However, he wants to destroy as few of them as possible. Help Byteazar to determine how many piggy banks have to be smashed. TaskWrite a programme which:
InputThe first line of the standard input contains a single integer N (1 <= N <= 1.000.000) - this is the number of piggy banks owned by the dragon. The piggy banks (as well as their corresponding keys) are numbered from 1 to N. Next, there are N lines: the i+1st line contains a single integer - the number of the piggy bank in which the ith key has been placed. OutputThe first and only line of the standard output should contain a single integer - the minimal number of piggy banks to be smashed in order to gain access to all of the piggy banks. ExampleFor the input data: 4 2 1 2 4 the correct outcome is: 2In the foregoing example piggy banks 1 and 4 have to be smashed. Print friendly version |