#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const double PI = (double)acos(-1.0);
const double EPS = (double)1e-9;
const long long MOD = (long long)1e9 + 7;
inline void swapp(int &a, int &b) { a ^= b ^= a ^= b; }
int n, dat[100005], res = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i += 1) scanf("%d", dat + i);
  dat[0] = 1;
  dat[n + 1] = n;
  for (int i = 1; i <= n; i += 1) {
    if (dat[i] != i) continue;
    if (dat[i - 1] != i)
      swapp(dat[i - 1], dat[i]);
    else
      swapp(dat[i], dat[i + 1]);
    res++;
  }
  printf("%d\n", res);
  return 0;
}
