#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans = 0, tmp1 = 0;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) {
    cin >> p[i];
    if (p[i] == i + 1) ++ans;
  }
  bool tmp2 = false;
  for (int i = 1; i < N; ++i) {
    if (p[i - 1] == i && p[i] == i + 1)
      tmp2 = true;
    else {
      if (tmp2) ++tmp1;
      tmp2 = false;
    }
  }
  if (tmp2) ++tmp1;
  ans -= tmp1;
  cout << ans;
}
