#include <bits/stdc++.h>
using namespace std;
int a[10005];
int find(int x) {
  int xx = a[x];
  if (xx != a[xx]) return find(xx);
  return xx;
}
void update(int x, int y) {
  if (find(x) == find(y)) return;
  a[x] = y;
  return;
}
int main() {
  int n, x, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) a[i] = i;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    update(i, x);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) ans++;
  }
  cout << ans << endl;
  return 0;
}
