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