#include <bits/stdc++.h>
using namespace std;
signed main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < (int)(N); i++) {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  int k = 0;
  for (int i = 0; i < (int)(N); i++) {
    if (p[i] == i) {
      k++;
    } else {
      if (k != 0) ans += max(1, k - 1);
      k = 0;
    }
  }
  if (k != 0) ans += max(1, k - 1);
  cout << ans << endl;
}
