#include <bits/stdc++.h>
using namespace std;
int par[10003];
int parent(int x) {
  if (par[x] == x) return x;
  return par[x] = parent(par[x]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 10002; i++) par[i] = i;
  for (int i = 1; i < n + 1; i++) {
    int x;
    scanf("%d", &x);
    int p1 = parent(x);
    int p2 = parent(i);
    if (p1 != p2) par[p1] = p2;
  }
  int c = 0;
  for (int i = 1; i < n + 1; i++) {
    if (par[i] == i) c++;
  }
  cout << c;
  return 0;
}
