#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  bool b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == i + 1) {
      b[i] = true;
    } else {
      b[i] = false;
    }
  }
  int cnt = 0;
  bool fo = false;
  for (int i = 0; i < n; i++) {
    if (b[i] == true) {
      if (fo == true) {
        cnt++;
        fo = false;
      } else {
        fo = true;
      }
    } else {
      if (fo == true) {
        cnt++;
        fo = false;
      }
    }
  }
  if (a[n - 1] == n) {
    cnt++;
  }
  cout << cnt;
  return 0;
}
