#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int j = 0; j < N; j++) {
    cin >> d.at(j);
    d.at(j)--;
  }
  int sw = 0;
  for (int i = 0; i < N - 1; i++) {
    if (d.at(i) == i && d.at(i + 1) != i + 1) {
      sw++;
    }
  }
  int a = 0;
  int b = 0;
  for (int i = 0; i < N - 1; i++) {
    if (d.at(i) == i && d.at(i + 1) == i + 1) {
      a++;
    } else {
      sw += a;
      a = 0;
    }
  }
  sw += a;
  for (int i = 1; i < N - 1; i++) {
    if (d.at(i - 1) == i - 1 && d.at(i) == i && d.at(i + 1) != i + 1) {
      b++;
    }
  }
  sw -= b;
  cout << sw << endl;
}
