#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[10001], counter = 0, i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    if (a[i] == i)
      counter += 2;
    else if (a[a[i]] == i)
      counter++;
  }
  cout << counter / 2;
  return 0;
}
