#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  int ans = 0;
  for (int i = 0; i < (int)(N); i++) {
    cin >> p[i];
    if (p[i] == i + 1) {
      ans++;
    }
  }
  if (ans % 2 == 1) {
    ans++;
  }
  cout << ans / 2 << endl;
}
