#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x, cnt = 0;
  set<int> s;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == i)
      cnt++;
    else {
      s.insert(x);
    }
  }
  cout << cnt + s.size() / 2 << "\n";
}
