#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int a[MAXN];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    a[0] = -1;
    int cnt = 0, t = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == i) {
        cnt++;
        if (a[i - 1] == i - 1) t++;
      }
    }
    printf("%d\n", cnt - t);
  }
  return 0;
}
