#42063: __ng


chinanmsl198964@gmail.com (120-36嚴琮傑)


n = int(input())
friends = list(map(int,input().split()))
flags = 0
Visited = set()
for i in range(n):
    if i  not in Visited:
        current = i
        Cycle = set()
        while True:
            if friends[current] == i:
                Cycle.add(current)
                break
            else:
                Cycle.add(current)
                current = friends[current]
        flags+=1
        Visited.update(Cycle)
        
print(flags,"\n")

2024/9/23