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