#include <bits/stdc++.h>
using namespace std;
int A[(int)1e5];
int N;
int isValid() {
  for (int i = 0; i < N; i++) {
    if (A[i] == i + 1) return i;
  }
  return -1;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  int count = 0, tempcount = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == i + 1)
      tempcount++;
    else if (tempcount != 0) {
      count += max(1, tempcount - 1);
      tempcount = 0;
    }
  }
  if (tempcount != 0) {
    count += max(1, tempcount - 1);
    tempcount = 0;
  }
  cout << count << "\n";
}
