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