#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool zone = false;
  int start = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    if (t == i) {
      if (!zone) start = i;
      if (i == n) ans += (i + 1 - start) / 2;
      zone = true;
    } else {
      if (zone) ans += (i + 1 - start) / 2;
      zone = false;
    }
  }
  cout << ans << endl;
  return 0;
}
