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