There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.
a=open(0).read().split();print(sum(a[int(x)]==x for x in a)//2)
*a,=map(int,open(0).read().split());print(sum(a[a[i]]==i for i in range(len(a)))//2)