#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7;
string yn(bool f) { return f ? "Yes" : "No"; }
string YN(bool f) { return f ? "YES" : "NO"; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  long long N, ans;
  vector<long long> p;
  cin >> N;
  p.resize(N);
  for (long long i = 0; i < N; i++) {
    cin >> p[i];
  }
  p.push_back(-1);
  for (long long i = 0, con = 0; i <= N; i++) {
    if (p[i] == i + 1) {
      con++;
    } else {
      if (con) ans += max(1ll, con - 1);
      con = 0;
    }
  }
  cout << ans << "\n";
  return 0;
}
