#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> plc(N + 2);
  plc[N + 1] = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &(plc[i]));
  }
  int ans = 0;
  int i = 1;
  while (i < N) {
    if (plc[i] == i && plc[i + 1] == i + 1) {
      ans++;
      i += 2;
    } else if (plc[i + 1] == i + 1 && plc[i + 2] == i + 2) {
      ans++;
      i += 3;
    } else if (plc[i] == i || plc[i + 1] == i + 1) {
      ans++;
      i += 2;
    } else {
      i++;
    }
  }
  cout << ans << endl;
}
