#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T>
inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <class T>
inline T LCM(T a, T b) {
  return a * b / GCD(a, b);
}
int main() {
  int n;
  cin >> n;
  int p[100010];
  vector<int> v;
  for (int i = 0; i < (n); i++) {
    cin >> p[i];
    if (i + 1 == p[i]) v.push_back(p[i]);
  }
  int cnt = 1, ans = 0;
  for (int i = 0; i < (max(0, (int)v.size() - 1)); i++) {
    if (v[i] + 1 == v[i + 1]) {
      cnt++;
    } else {
      if (cnt >= 2) cnt--;
      ans += cnt;
      cnt = 1;
    }
  }
  if (cnt >= 2) cnt--;
  ans += cnt;
  if ((int)v.size() == 0) ans = 0;
  cout << ans << endl;
}
