#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
signed main() {
  int n;
  cin >> n;
  int p[n], q[n];
  for (int i = 0; i < (n); i++) {
    cin >> p[i];
    q[i] = p[i];
  }
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < (n - 1); i++) {
    if (p[i] == i + 1) {
      int t = p[i];
      p[i] = p[i + 1];
      p[i + 1] = t;
      ans1++;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (q[i] == i + 1) {
      int t = q[i];
      q[i] = q[i - 1];
      q[i - 1] = t;
      ans2++;
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}
