N = int(input()) p = list(map(int, input().split())) pos = [0] * N ans = 0 for i in range(N): p[i] -= 1 pos[p[i]] = i for i in range(N): if p[i] != i: j = pos[i] p[i], p[j] = p[j], p[i] pos[p[i]], pos[p[j]] = pos[p[j]], pos[p[i]] ans += 1 print(ans)