#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  bool mask = 0;
  for (int i = 0; i < (n); ++i) cin >> p[i];
  for (int i = 0; i < (n); ++i) {
    if (i == n - 1 && (p[i - 1] == i || p[i] == i + 1)) {
      swap(p[i - 1], p[i]);
      ++cnt;
    }
    if (mask) {
      mask = 0;
      continue;
    }
    if (p[i] == i + 1 || p[i + 1] == i + 2) {
      swap(p[i], p[i + 1]);
      ++cnt;
      mask = 1;
    }
  }
  cout << cnt << endl;
  return 0;
}
