|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|3 초||512 MB||11||6||6||54.545%|
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:
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