class Unionfind: def __init__(self, size): self.root = [x for x in range(size + 1)] self.rank = [1] * (size + 1) def find(self, x): if x != self.root[x]: self.root[x] = self.find(self.root[x]) return self.root[x] def union(self, x, y): rootx = self.find(x) rooty = self.find(y) if rootx != rooty: if self.rank[rootx] > self.rank[rooty]: self.root[rooty] = rootx elif self.rank[rootx] < self.rank[rooty]: self.root[rootx] = rooty else: self.root[rooty] = rootx self.rank[rootx] += 1 def connected(self, x, y): return self.find(x) == self.find(y) n = int(input()) a = list(map(int, input().split())) res = 0 visit = set() for i in range(n): t = a[i]-1 if t in visit: continue while not t in visit: visit.add(t) t = a[t]-1 res += 1 print(res)