n = int(input())
friends_array = list(map(int, input().split()))
marked = [False] * n
counter = 0
for i in range(n):
if not marked[i]:
# 追蹤整個朋友圈,標記所有相關的人
current = i
while not marked[current]:
marked[current] = True
current = friends_array[current]
counter += 1
print(counter)