#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cnt = 0, continuous = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    bool flg, flg_n, flg_cnt;
    if (p == i + 1) {
      cnt++;
      flg = true;
    } else
      flg = false;
    if (flg && flg_n && i > 0)
      flg_cnt = true;
    else
      flg_cnt = false;
    if (flg_cnt)
      continuous++;
    else {
      if (continuous % 2 == 0)
        cnt -= continuous / 2;
      else
        cnt -= (continuous + 1) / 2;
      continuous = 0;
    }
    flg_n = flg;
  }
  cout << cnt << endl;
  return 0;
}
