#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> P(N);
  for (int i = 0; i < N; i++) cin >> P[i];
  long long ans = 0;
  long long ct = 0;
  for (int i = 0; i < N; i++) {
    if (ct == 1 && P[i] == i + 1) {
      ans++;
      ct = 0;
    } else if (ct == 1) {
      ans++;
      ct = 0;
    } else if (P[i] == i + 1)
      ct++;
    else
      ct = 0;
  }
  if (P[0] == 1 && P[1] != 2 && P[2] != 3)
    ans++;
  else if (P[N - 1] == N && P[N - 2] != N - 1 && P[N - 3] != N - 2)
    ans++;
  cout << ans << endl;
}
