#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long n, tmp, ans;
  cin >> n;
  bool flag[n];
  bool ok;
  for (long long i = 0; i < (n); i++) flag[i] = false;
  for (long long i = 0; i < (n); i++) {
    long long p;
    cin >> p;
    p--;
    if (p == i) flag[i] = true;
  }
  ans = 0;
  ok = false;
  for (long long i = 0; i < (n); i++) {
    if (flag[i]) {
      if (ok) {
        ans += i - tmp;
        ok = false;
      } else {
        tmp = i;
        ok = true;
      }
    }
  }
  if (ok) ans += 1;
  cout << ans << endl;
  return 0;
}
