n=int(input()) L=list(map(int,input().split())) ans=0 for i in range(n): if L[i]==0: pass else: if L[L[i]-1]!=0: ans+=1 print(ans)