#include <bits/stdc++.h>
using namespace std;
int pre[10000 + 5];
int find_yasuo(int root) {
  int son = root, temp;
  while (root != pre[root]) root = pre[root];
  while (son != root) {
    temp = pre[son];
    pre[son] = root;
    son = temp;
  }
  return root;
}
int main() {
  int a[10000 + 5];
  int x, n, i, j, ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) pre[i] = i;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    int f1 = find_yasuo(a[i]);
    int f2 = find_yasuo(i);
    if (f1 != f2) pre[f1] = f2;
  }
  for (i = 1; i <= n; i++)
    if (pre[i] == i) ans++;
  printf("%d", ans);
  return 0;
}
