#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1e18;
int main() {
  long long n;
  cin >> n;
  vector<long long> p(n), q(n);
  long long cnt1 = 0, cnt2 = 0;
  for (long long i = 0; i < (n); i++) {
    cin >> p[i];
    p[i]--;
  }
  q = p;
  for (long long i = 0; i < (n - 1); i++) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      cnt1++;
    }
  }
  for (long long i = 0; i < (n - 1); i++) {
    if (q[i + 1] == i + 1) {
      swap(q[i + 1], q[i]);
      cnt2++;
    }
  }
  long long cnt = min(cnt1, cnt2);
  cout << cnt << endl;
}
