#include <bits/stdc++.h>
using namespace std;
vector<int> f;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k, cont = 0, cont1 = 0;
  cin >> n;
  f.push_back(0);
  for (int i = 1; i <= n; i++) {
    cin >> k;
    f.push_back(k);
    if (k == i) cont++;
  }
  for (int i = 1; i <= n; i++) {
    if (f[f[i]] == i && f[i] != i) cont1++;
  }
  cout << cont + cont1 / 2 << '\n';
  return 0;
}
