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