#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toLL(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> p[i];
  }
  bool flag = false;
  long long cnt = 0;
  vector<int> v;
  for (long long i = 0; i < (long long)(n); i++) {
    if (p[i] == i + 1) {
      if (flag) {
        cnt++;
      } else {
        flag = true;
        cnt = 1;
      }
    } else {
      if (cnt > 0) {
        v.push_back(cnt);
        cnt = 0;
        flag = false;
      }
    }
  }
  if (cnt > 0) {
    v.push_back(cnt);
    cnt = 0;
    flag = false;
  }
  long long ans = 0;
  for (long long i = 0; i < (long long)(v.size()); i++) {
    if (v[i] == 1) {
      ans += 1;
    } else {
      ans += v[i] - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
