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