#include <bits/stdc++.h>
using namespace std;
long long parent[10101], r[10101], N, x, ans;
long long find(long long u) {
  return u == parent[u] ? u : (parent[u] = find(parent[u]));
}
long long same(long long u, long long v) { return find(u) == find(v); }
void join(long long u, long long v) {
  if (!same(u, v)) {
    --ans;
    long long x = find(u);
    long long y = find(v);
    if (r[x] > r[y]) {
      parent[y] = x;
    } else {
      parent[x] = y;
      if (r[x] == r[y]) ++r[y];
    }
  }
}
int main() {
  cin >> N;
  ans = N;
  for (int i = 1; i <= N; i++) parent[i] = i, r[i] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> x;
    join(x, i);
  }
  cout << ans << endl;
  return 0;
}
