GlobeX Cup '18 S1 - Code Copiers

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

Code copying is a major problem on many online programming judges. There are N coders, of which some of them copy code from others. Coder i knows that only coder ai copied from them.

There are always some "sources" from which coders copy from. A "source" is defined as a coder who does not copy from anyone. Your task is to find out how many "sources" there are.

Input Specification

The first line will contain the integer N (1N106), the number of coders there are.

The second line will contain N integers, a1,a2,,aN (0ai<i). The ith integer means that coder ai copies from coder i. If ai=0, this means no coders copies from coder i.

Output Specification

Output the number of "sources".

Constraints

Subtask 1 [20%]

N1000

Subtask 2 [80%]

No additional constraints.

Sample Input 1

Copy
5
0 1 1 3 2

Sample Output 1

Copy
2

Sample Input 2

Copy
9
0 1 1 3 4 5 6 4 6

Sample Output 2

Copy
4

Comments

There are no comments at the moment.