#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n + 1);
  for (long long i = 1; i < n + 1; i++) cin >> A[i];
  int cnt = 0;
  if (A[1] == 1) cnt++, swap(A[1], A[2]);
  if (A[n] == n) cnt++, swap(A[n], A[n - 1]);
  for (long long i = 2; i < n; i++) {
    if (A[i] != i) continue;
    if (A[i - 1] != i and A[i] != i - 1) {
      swap(A[i], A[i - 1]);
      cnt++;
      continue;
    }
    if (A[i + 1] != i and A[i] != i + 1) {
      swap(A[i], A[i + 1]);
      cnt++;
      continue;
    }
    assert(false);
  }
  cout << cnt << endl;
  return 0;
}
