#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  int chain = 0;
  for (int i = 0; i < n; i++) {
    int p;
    scanf("%d", &p);
    if (p == i + 1) {
      chain++;
    } else {
      ans += (chain + 1) / 2;
      chain = 0;
    }
  }
  ans += (chain++) / 2;
  printf("%d\n", ans);
  return 0;
}
