#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int num, i, a, sum = 0, ans = 0;
  cin >> num;
  for (i = 1; i <= num; i++) {
    scanf("%d", &a);
    if (a == i)
      sum++;
    else if (sum > 0) {
      if (sum == 1)
        ans++;
      else
        ans += sum - 1;
      sum = 0;
    }
  }
  if (sum == 1)
    ans++;
  else if (sum > 0)
    ans += sum - 1;
  printf("%d\n", ans);
  return 0;
}
