#include <bits/stdc++.h>
using namespace std;
long n;
long p[100000 + 10];
int main() {
  cin >> n;
  for (long i = 1; i <= n; i++) {
    cin >> p[i];
  }
  p[n + 1] = -1;
  long count = 0;
  bool containsFlag = false;
  bool countTmp = 0;
  for (long i = 1; i <= n + 1; i++) {
    if (i == p[i]) {
      if (containsFlag == false) {
        containsFlag = true;
        countTmp = 1;
      } else {
        countTmp++;
      }
    } else {
      if (containsFlag == false) {
        continue;
      } else {
        containsFlag = true;
        if (countTmp % 2 == 0) {
          count += countTmp / 2;
        } else {
          count += countTmp / 2 + 1;
        }
        countTmp = 0;
      }
    }
  }
  cout << count << endl;
}
