n = int(input()) p = list(map(int,input().split())) for i in range(n): p[i] -= 1 from collections import * d = defaultdict(int) for i in range(n): d[p[i]] = i #インデックスを保持 ans = 0 for i in range(n): #print(p) if d[i] == i: continue ind = d[i] #print(ind,"ind") d[p[i]] = ind d[i] = i p[ind] = p[i] p[i] = i ans += 1 print(ans)