#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  int ans = 0;
  int check = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x == i + 1) {
      check++;
      ans += 1;
    } else {
      if (check >= 2) {
        ans--;
      }
      check = 0;
    }
  }
  if (check >= 2) {
    ans--;
  }
  cout << ans << endl;
}
