#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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < (int)(n); i++) cin >> p[i];
  int ans;
  int cur = 0;
  int len = 0;
  for (int i = 0; i < (int)(n - 1); i++) {
    if (p[i] == i + 1) {
      if (!cur) cur = 1;
      len++;
    } else if (cur) {
      cur = 0;
      ans += (len + 1) / 2;
      len = 0;
    }
  }
  if (cur) ans++;
  cout << ans << endl;
}
