#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
  int n;
  vector<int> p;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    int x;
    cin >> x;
    p.push_back(x);
  }
  int cnt = 0;
  bool preflag = false;
  bool renzoku = false;
  for (long long i = 0; i < n; i++) {
    if (p[i] == i + 1) {
      if (preflag && !renzoku) {
        cnt--;
        renzoku = true;
      }
      cnt++;
      preflag = true;
    } else {
      preflag = false;
      renzoku = false;
    }
  }
  cout << cnt << endl;
}
