题目链接:B - Takahashi's Secret (atcoder.jp)
Problem Statement
Takahashi has N friends. They have nicknames: Friend 1, Friend 2, …, Friend N.
One day, Takahashi accidentally let one of his friends, Friend X, learn his shameful secret.
For each i = 1,2,…,N, when Friend ii learns the secret, he/she will share it with Friend Ai, if Friend Ai has not already learned it.
How many of Takahashi's friends will learn the secret in the end?
Constraints
- 2≤N≤105
- 1≤X≤N
- 1≤Ai≤N
- Ai!=i
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X A1 A2 ... AN
Output
Print the answer.
Sample Input 1 Copy
4 2 3