#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll p[1000000] = {0};
int main() {
  ll N;
  cin >> N;
  for (ll n = 1; n <= N; n++) {
    cin >> p[n];
  }
  ll cnt = 0;
  if (p[1] == 1) {
    swap(p[1], p[2]);
    cnt++;
  }
  for (ll n = 2; n < N; n++) {
    if (p[n] == n) {
      ll prevlen = n - p[n - 1];
      ll nextlen = p[n + 1] - n;
      if (prevlen <= 0 && nextlen <= 0) {
        if (prevlen < nextlen) {
          swap(p[n], p[n - 1]);
        } else {
          swap(p[n], p[n + 1]);
        }
        cnt++;
        continue;
      }
      if (prevlen > nextlen) {
        swap(p[n], p[n - 1]);
      } else {
        swap(p[n], p[n + 1]);
      }
      cnt++;
    }
  }
  if (p[N] == N) {
    swap(p[N], p[N - 1]);
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
