#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int p[n];
  long long ans = 0;
  bool check = false;
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  for (int i = 0; i < n; i++) {
    if (p[i] == i + 1) {
      if (i != 0 && p[i - 1] == i) check = true;
      ans += 1;
    } else {
      if (check) ans -= 1;
      check = false;
    }
  }
  if (check) ans -= 1;
  cout << ans << endl;
  return 0;
}
