#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, d, p[10001], cnt[10001];
int get(int x) { return x == p[x] ? x : p[x] = get(p[x]); }
void join(int x, int y) {
  int p1 = get(x), p2 = get(y);
  if (p1 != p2) {
    cnt[p1] += cnt[p2];
    cnt[p2] = 0;
    p[p2] = p1;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    p[i] = i;
    cnt[i] = 1;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d);
    join(i, d - 1);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (cnt[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
