#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
template <class t, class u>
void chmax(t& a, u b) {
  if (a < b) a = b;
}
template <class t, class u>
void chmin(t& a, u b) {
  if (b < a) a = b;
}
int main() {
  int n;
  cin >> n;
  bool ok = false;
  int cnt = 0;
  ll ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    int a;
    cin >> a;
    if (a == i + 1 && ok) {
      cnt++;
    } else if (a != i + 1 && ok) {
      cnt--;
      ans += cnt + (cnt == 0 ? 1 : 0);
      cnt = 0;
      ok = false;
    } else if (a == i + 1 && !ok) {
      cnt++;
      ok = true;
    }
  }
  if (ok) {
    cnt--;
    ans += cnt + (cnt == 0 ? 1 : 0);
  }
  cout << ans << endl;
}
