#include <bits/stdc++.h>
int Calc(int n);
int main() {
  int n, i, ans;
  if (scanf("%d", &n) != 1) {
    scanf("%*s");
    goto TRY_TAG_ERROR;
  }
  ans = Calc(n);
  if (ans == -1) goto TRY_TAG_ERROR;
  printf("%d\n", ans);
  return 0;
TRY_TAG_ERROR : {
  puts("入力エラー\n");
  return -1;
}
  return 0;
}
int Calc(int n) {
  int i, ans = 0;
  int tmp;
  for (i = 0; i < n; i++) {
    if (scanf("%d", &tmp) != 1) {
      scanf("%*s");
      return -1;
    }
    if (i == tmp - 1) {
      ans++;
      i++;
      if (scanf("%d", &tmp) != 1) {
        scanf("%*s");
        return -1;
      }
    }
  }
  return ans;
}
