#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9 + 7;
const int INF = 1000 * 1000 * 1000;
const ll LINF = (ll)1e18;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool prev = false;
  ll cnt = 0;
  ll ans = 0;
  vector<int> p(N);
  for (int(i) = 0; (i) < (N); (i)++) {
    int p;
    cin >> p;
    p--;
    if (i == p) {
      cnt++;
    } else {
      if (cnt >= 2) {
        ans += cnt - 1;
      } else {
        ans += cnt;
      }
      cnt = 0;
    }
  }
  if (cnt >= 2) {
    ans += cnt - 1;
  } else {
    ans += cnt;
  }
  cnt = 0;
  cout << ans << endl;
  return 0;
}
