#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n;
  int p[n];
  int w[n];
  int ans = 0;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> p[i];
  }
  for (int i = 0; i <= n - 1; i++) {
    if (p[i] == i + 1) {
      ++ans;
    }
  }
  int ref = 0;
  while (ref <= n - 2) {
    if (p[ref] == ref + 1 && p[ref + 1] == ref + 2) {
      --ans;
      ref += 2;
    } else {
      ++ref;
    }
  }
  cout << ans << endl;
}
