#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0, accum = 0;
  for (int i = 0; i < n - 1; i++) {
    if (i + 1 == p[i]) {
      accum++;
    } else {
      if (accum > 0) ans += max(1, accum - 1);
      accum = 0;
    }
  }
  if (accum > 0) ans += max(1, accum - 1);
  cout << ans << endl;
  return 0;
}
