#include <bits/stdc++.h>
const char sp = ' ';
using namespace std;
int main(void) {
  long long N;
  long long p;
  cin >> N;
  long long count = 0;
  long long thc = 0;
  for (int i = 1, i_len = (N); i <= i_len; ++i) {
    cin >> p;
    if (p == i)
      thc++;
    else {
      if (thc >= 1) count += max(thc - 1, (long long)1);
      thc = 0;
    }
  }
  if (thc >= 1) count += max(thc - 1, (long long)1);
  thc = 0;
  cout << count << endl;
  return 0;
}
