#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, i, j, k, count;
  cin >> N;
  int a[N], b[N];
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  if (N == 2) {
    if (a[0] == 1)
      cout << 1;
    else
      cout << 0;
  } else {
    if (a[0] == 1) {
      count++;
      k = a[0];
      a[0] = a[1];
      a[1] = k;
    }
    if (a[N - 1] == N) {
      count++;
      k = a[N - 2];
      a[N - 2] = a[N - 1];
      a[N - 1] = k;
    }
    for (i = 0; i < N;) {
      if (a[i] == i + 1) {
        count++;
        i = i + 2;
      } else
        i++;
    }
    cout << count;
  }
}
