#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0, lasti = 0;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == i) {
      ans++;
      i++;
      lasti = i;
    }
  }
  if ((n - 1) % 2 == lasti % 2 && p[n - 1] == n - 1) ans++;
  cout << ans << endl;
  return 0;
}
