#include <bits/stdc++.h>
using namespace ::std;
template <class T>
istream& operator>>(istream& I, vector<T>& v) {
  for (T& e : v) I >> e;
  return I;
}
template <class T>
ostream& operator<<(ostream& O, const vector<T>& v) {
  for (const T& e : v) O << e << ' ';
  return O;
}
void _main() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  auto x = [&](int i) { return i + 1 == a[i]; };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 < n &&
        ((x(i) && x(i + 1)) || (x(i) && !x(i + 1)) || (!x(i) && x(i + 1)))) {
      swap(a[i], a[i + 1]);
      ans++;
    }
  }
  for (int i = 0; i < n; i++) assert(i + 1 != a[i]);
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int _t = 1;
  while (_t--) _main();
  return 0;
}
