#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 7;
int p[MAXN], x[MAXN], y[MAXN];
bool mark[MAXN];
int find(int a) {
  if (p[a] == a) return a;
  return p[a] = find(p[a]);
}
void merge(int a, int b) {
  a = find(a);
  b = find(b);
  p[a] = b;
}
int main() {
  for (int i = 0; i < MAXN; i++) {
    p[i] = i;
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    merge(i, x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (find(i) == i) ans++;
  }
  printf("%d", ans);
  return 0;
}
