#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
inline long long in() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int32_t main() {
  long long n = in();
  vector<long long> a(n);
  for (auto &i : a) i = in();
  long long ans = 0;
  long long tmp = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] == (i + 1))
      tmp++;
    else {
      if (tmp > 1)
        ans += tmp - 1;
      else
        ans += tmp;
      tmp = 0;
    }
  }
  if (tmp > 1)
    ans += tmp - 1;
  else
    ans += tmp;
  cout << ans;
}
