#include <bits/stdc++.h>
using namespace std;
int myswap(int *array, int length) {
  int count = 0;
  for (int i = 0; i < length - 1; i++) {
    if (array[i] == i + 1) {
      count++;
      int temp = array[i];
      array[i] = array[i + 1];
      array[i + 1] = temp;
    }
  }
  if (array[length - 1] == length)
    return 1000000;
  else
    return count;
}
int main() {
  int N;
  cin >> N;
  int p1[100000], p2[100000];
  for (int i = 0; i < N; i++) {
    cin >> p1[i];
    p2[i] = p1[i];
  }
  cout << min(myswap(p1, N), myswap(p2, N));
}
