#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int answer = 0;
  int p, q, r = 0;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) == i + 1) {
      if (r == 0) {
        p = i + 1;
        r++;
      } else {
        r = 0;
        q = i + 1;
        answer += q - p;
      }
    }
  }
  if (r == 1) {
    answer++;
  }
  cout << answer << endl;
}
