#codefestival2016qualAb. [codefestival_2016_qualA_b]Friendly Rabbits
[codefestival_2016_qualA_b]Friendly Rabbits
Problem Statement
There are rabbits, numbered through .
The -th () rabbit likes rabbit . Note that no rabbit can like itself, that is, .
For a pair of rabbits and (), we call the pair () a friendly pair if the following condition is met.
- Rabbit likes rabbit and rabbit likes rabbit .
Calculate the number of the friendly pairs.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the number of the friendly pairs.
Sample Input 1
4
2 1 4 3
Sample Output 1
2
There are two friendly pairs: and .
Sample Input 2
3
2 3 1
Sample Output 2
0
There are no friendly pairs.
Sample Input 3
5
5 5 5 5 1
Sample Output 3
1
There is one friendly pair: .