#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == i + 1)
      cnt++;
    else {
      if (cnt == 0)
        continue;
      else
        ans += max(1, cnt - 1);
      cnt = 0;
    }
  }
  if (cnt > 0) ans += max(1, cnt - 1);
  cout << ans << endl;
  return 0;
}
