#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < (n); ++i) cin >> p.at(i);
  vector<int> q(n);
  for (int i = 0; i < (n); ++i) q.at(i) = p.at(i);
  int ans1 = 0;
  for (int i = 0; i < (n - 1); ++i) {
    if (p[i] == i + 1) {
      ans1++;
      swap(p[i], p[i + 1]);
    }
  }
  int ans2 = 0;
  for (int i = n - 1; i > 0; i--) {
    if (q[i] == i + 1) {
      ans2++;
      swap(q[i], q[i - 1]);
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}
