#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  int cnt = 0, ren = 1;
  for (int i = int(1); i < int(n + 1); ++i) {
    cin >> a[i];
    if (a[i] == i) {
      if (a[i - 1] == i - 1)
        ren++;
      else {
        cnt += (ren + 1) / 2;
        ren = 1;
      }
    }
    if (i == n && ren != 1) cnt += (ren + 1) / 2;
  }
  cout << cnt - 1;
}
