#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 10005, Mo = 1000000007;
char s[MAXN], ch;
int n, m, a[MAXN], b[MAXN], c[MAXN];
int main() {
  int i, j, k;
  n = read();
  m = 0;
  for (i = 1; i <= n; ++i) a[i] = read();
  memset(b, 0, sizeof(b));
  for (i = 1; i <= n; ++i)
    if (!b[i]) {
      m++;
      b[i] = i;
      k = a[i];
      while (!b[k]) {
        b[k] = i;
        k = a[k];
      }
      if (b[k] != i) m--;
    }
  printf("%d\n", m);
  return 0;
}
