n,*a=map(int,open(0).read().split()) s=[0]*n ans=0 for i in range(n): if s[i]: continue while s[i]<1: s[i]=1 i=a[i]-1 ans+=1 print(ans)