#include <bits/stdc++.h>
using namespace std;
const int maxn = 10050;
int n, m, tmp[maxn], f[maxn];
int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }
void init() {
  for (int i = 1; i <= n; ++i) {
    f[i] = i;
  }
}
int main() {
  int x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &tmp[i]);
  init();
  for (int i = 1; i <= n; ++i) {
    if (Find(i) != Find(tmp[i])) f[i] = f[tmp[i]];
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (Find(i) == i) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}
