#include <bits/stdc++.h>
int c[100001];
int main(void) {
  int n, a = 1, m = 0;
  scanf("%d", &n);
  int p[n + 1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    if (i == p[i]) {
      m++;
      if (i - 1 == p[i - 1])
        c[a]++;
      else
        a++;
    }
  }
  for (int i = 1; i <= a; i++) {
    if (c[i] % 2 == 0)
      m -= c[i] / 2;
    else if (c[i] % 2 == 1)
      m -= (c[i] + 1) / 2;
  }
  printf("%d", m);
  return 0;
}
