#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, tmp, countp = 0, countq = 0;
  vector<long long> p, q;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> tmp;
    p.push_back(tmp);
    q.push_back(tmp);
  }
  for (long long i = 0; i < p.size() - 1; i++) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      countp++;
    } else if (p[i + 1] == i + 1 + 1) {
      swap(p[i], p[i + 1]);
      countp++;
    }
  }
  for (long long i = q.size() - 1; i > 0; i--) {
    if (q[i] == i + 1) {
      swap(q[i], q[i - 1]);
      countq++;
    } else if (q[i - 1] == i - 1 + 1) {
      swap(q[i], q[i - 1]);
      countq++;
    }
  }
  if (countp > countq) {
    cout << countq;
  } else {
    cout << countp;
  }
  return 0;
}
