#include <bits/stdc++.h>
using namespace std;
int p[100000], rk[100000];
void init_dsu() {
  for (int i = 0; i < 100000; i++) {
    p[i] = i;
    rk[i] = 1;
  }
}
int get_root(int v) {
  if (p[v] == v) {
    return v;
  } else {
    return get_root(p[v]);
  }
}
bool merge(int a, int b) {
  int ra = get_root(a), rb = get_root(b);
  if (ra == rb) {
    return false;
  } else {
    if (rk[ra] < rk[rb]) {
      p[ra] = rb;
    } else if (rk[rb] < rk[ra]) {
      p[rb] = ra;
    } else {
      p[ra] = rb;
      rk[rb]++;
    }
    return true;
  }
}
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    p[i] = i;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    if (merge(i, a) == 0) {
      ans++;
    }
  }
  cout << ans;
}
