#include <bits/stdc++.h>
using namespace std;
int N, t;
vector<int> p, out;
int main() {
  bool flag = false;
  int count = 0, temp = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &t), p.push_back(t);
    if (t == i + 1) {
      temp++;
      flag = true;
      out.push_back(t);
    } else {
      if (flag) {
        count += temp / 2 + 1;
      }
      flag = false, temp = 0;
    }
  }
  if (flag) {
    count += temp / 2 + 1;
  }
  flag = false;
  printf("%d", count);
  return 0;
}
