#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> p(N + 2, 0);
  for (int i = 1; i <= N; i++) cin >> p[i];
  int ans = 0;
  bool flg = false;
  int cnt = 0;
  for (int i = 1; i <= N + 1; i++) {
    if (flg == false && p[i] == i) {
      flg = true;
    } else if (flg == true && p[i] == i) {
      cnt++;
    } else if (flg == true && p[i] != i) {
      ans += (cnt - 1) / 2 + 1;
      cnt = 0;
      flg = false;
    }
  }
  cout << ans << endl;
}
