Spies

No attempts yetTime limit3sMemory limit512 MB

Problem

An intelligence agency employs nn spies. Each spy shadows exactly one other spy. This shadowing assignment is fixed: spy kk shadows spy aka_k (with akka_k \ne k).

The agency wants to assign as many spies as possible to a secret operation. However, every spy taking part in the operation must be shadowed by at least one spy that does not take part in it. (The shadowing assignment never changes.)

Write a program that:

  • reads from standard input which spy each spy shadows,
  • computes the maximum number of spies that can be assigned to the operation so that each of them is shadowed by at least one spy not taking part in the operation,
  • writes the result to standard output.

Input

The first line contains the number of spies nn (2n1062 \le n \le 10^6). The spies are numbered from 11 to nn. Each of the next nn lines describes whom a spy shadows: the (k+1)(k+1)-th line contains a single integer aka_k, meaning that spy kk shadows spy aka_k (1kn1 \le k \le n, 1akn1 \le a_k \le n, akka_k \ne k).

Output

Print a single integer: the maximum number of spies that can be assigned to the secret operation.

Hint