#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    if (p[i] == i + 1) {
      cnt++;
    }
  }
  int ad = 0;
  bool c = false;
  for (int i = 1; i < n; i++) {
    if (p[i - 1] == i && p[i] == i + 1) {
      if (c) {
        continue;
      } else {
        ad++;
      }
    } else {
      c = false;
    }
  }
  cout << cnt - ad << endl;
}
