#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1e18;
int main() {
  long long n;
  cin >> n;
  vector<long long> p(n);
  long long cnt = 0;
  for (long long i = 0; i < (n); i++) {
    cin >> p[i];
    p[i]--;
    if (p[i] == i) cnt++;
  }
  cout << (cnt - 1) / 2 << endl;
}
