#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < (n); i++) cin >> p[i];
  int cnt = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i - 1] == i)
      cnt++;
    else {
      if (cnt == 1) {
        ans++;
        cnt = 0;
      } else {
        ans += cnt / 2;
        cnt = 0;
      }
    }
  }
  if (cnt == 1) {
    ans++;
  } else {
    ans += cnt / 2;
  }
  cout << ans << endl;
  return 0;
}
