#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long count = 0;
  int num = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == i + 1)
      num++;
    else {
      if (num >= 2)
        count += num - 1;
      else if (num == 1)
        count += 1;
      num = 0;
    }
  }
  if (num >= 2)
    count += num - 1;
  else if (num == 1)
    count += 1;
  cout << count << endl;
  return 0;
}
