시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 512 MB 7 3 3 42.857%

문제

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

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 ≤ 1,000,000. 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.

예제 입력

6
2
3
1
3
6
5

예제 출력

3

힌트