class DisjointSetUnion(): def __init__(self, n): self.n = n self.par_or_size = [-1] * n def merge(self, a, b): assert(0 <= a < self.n) assert(0 <= b < self.n) la = self.leader(a) lb = self.leader(b) if la == lb: return la if -self.par_or_size[la] < -self.par_or_size[lb]: la, lb = lb, la self.par_or_size[la] += self.par_or_size[lb] self.par_or_size[lb] = la return la def same(self, a, b): assert(0 <= a < self.n) assert(0 <= b < self.n) return self.leader(a) == self.leader(b) def leader(self, a): assert(0 <= a < self.n) if (self.par_or_size[a] < 0): return a else: self.par_or_size[a] = self.leader(self.par_or_size[a]) return self.par_or_size[a] def size(self, a): assert(0 <= a < self.n) return - self.par_or_size[self.leader(a)] def group(self): result = dict() for a in range(self.n): la = self.leader(a) if la not in result: result[la] = [] result[la].append(a) return result N = int(input()) dsu = DisjointSetUnion(N) P = list(map(int, input().split())) for i in range(N): dsu.merge(i, P[i] - 1) g = dsu.group() print(N - len(g))