1384. Spies

单点时限: 2.0 sec

内存限制: 256 MB

Byteotian Intelligence Agency (BIA) employs many spies. Each of them has duty to shadow exactly one other spy.

King Byteasar wants to entrust as many agents as possible with a top secret operation. However, the operation is so important that each spy taking part has to be traced by at least one agent not involved in the operation (assignment of shadowing BIA spies does not change).

Task

Write a programme that:

reads from standard input the description of whom each spy shadows,

calculates how many agents can be assigned to the operation in a way that each of them would be spied by at least one agent not taking part in the operation,

writes the result to the standard output.

输入格式

In the first line of the input there is one positive integer written, n - the number of spies, 2 <= n <= 1000000. The spies are numbered from 1 to n. In the following n lines there is a description of whom each agent spies. Each of these lines contains one positive integer. A number ak situated in line no. k + 1 indicates, that the spy no. k shadows the spy no. ak, 1 <= k <= n, 1 <= ak <= n, ak <> k.

输出格式

Your programme should write one integer in the first line of the output - the maximal number of spies that can be assigned to the secret operation.

样例

Input
6
2
3
l
3
6
5
Output
3
hint:

1 人解决,1 人已尝试。

1 份提交通过,共有 2 份提交。

9.2 EMB 奖励。

创建: 16 年,9 月前.

修改: 6 年,8 月前.

最后提交: 5 年,1 月前.

来源: POI

题目标签