#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long double pi = acos(-1.0);
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long cnt = 0;
  long long len = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    long long a;
    cin >> a;
    if (a == i + 1) {
      len++;
    } else {
      if (len == 1)
        cnt++;
      else if (len > 1)
        cnt += len - 1;
      len = 0;
    }
  }
  if (len == 1)
    cnt++;
  else if (len > 1)
    cnt += len - 1;
  cout << cnt << endl;
  return 0;
}
