#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, a, t = 0, f = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (i == a) {
      if (f > 0) {
        t++;
        f = 0;
      } else {
        f = 1;
      }
    } else {
      if (f > 0) {
        t++;
      }
    }
  }
  cout << t << endl;
}
