1397. Piggy banks

单点时限: 10.0 sec

内存限制: 256 MB

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.

Task

Write a programme which:

reads from the standard input the number of piggy banks and the deployment of their corresponding keys,

finds the minimal number of piggy banks to be smashed in order to gain access to all of them,

writes the outcome to the standard output.

输入格式

The 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.

输出格式

The 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.

样例

Input
4
2
1
2
4
Output
2

0 人解决,3 人已尝试。

0 份提交通过,共有 43 份提交。

9.9 EMB 奖励。

创建: 17 年,3 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: POI

题目标签