#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 1e8 + 10;
int P[maxn];
int Q[maxn];
int main() {
  int ans = 0;
  int n;
  scanf("%d", &n);
  int a = 0, b = 0;
  for (long long i = 1; i < n + 1; i++) {
    int k;
    scanf("%d", &k);
    if (k == i) {
      if (a == 1) {
        ans++;
        a = 0;
        b = 0;
      } else
        a = 1;
    } else {
      if (a == 1) {
        ans++;
        a = 0;
      } else
        b = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
