#P10933. 创世纪

创世纪

Problem Description

God has NN types of world elements. Each element can restrain exactly 11 other element. Let the element that the ii-th world element can restrain be A[i]A[i].

Now, God wants to place some of them into a new space to build a world.

For the peace and safety of the world, God hopes that for every placed world element, there exists at least one world element that can restrain it that is not placed.

God wants to know: under this condition, what is the maximum number of world elements he can place?

Input Format

The first line contains an integer NN, representing the number of world elements.

The second line contains NN integers A[1],A[2],,A[N]A[1], A[2], \dots, A[N]. A[i]A[i] represents the index of the world element that the ii-th world element can restrain.

Output Format

Output one integer, representing the maximum number of world elements that can be placed.

6
2 3 1 3 6 5
3

Hint

Constraints: 1N1061\le N \le 10^6, 1A[i]N1 \le A[i] \le N.

Translated by ChatGPT 5