#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  long p;
  long count = 0;
  for (int i = 0; i < N; i++) {
    cin >> p;
    if (p == i + 1) count++;
  }
  if (!count % 2)
    cout << count / 2 << endl;
  else
    cout << count / 2 + 1 << endl;
  return 0;
}
