while 1:
try:
def trace(x):
if i != x:
a=jojo[x]
jojo[x]=-1
return trace(a)
else:
global team
team += 1
return 0
number=int(input())
jojo=list(map(int,input().split()))
global team
team = 0
for i in range(number):
if jojo[i] != -1:
trace(jojo[i])
print(team)
except EOFError:
break