#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  LL ans = 0;
  int N;
  cin >> N;
  vector<int> p(N);
  for (int(i) = (0); (i) < (N); (i)++) {
    cin >> p[i];
  }
  bool flag = false;
  for (int(i) = (0); (i) < (N); (i)++) {
    if (p[i] == i + 1) {
      ans++;
      if (i != 0 && p[i - 1] == i) {
        flag = true;
      }
    }
    if (p[i] != i + 1 && flag) {
      flag = false;
      ans--;
    }
  }
  if (flag) {
    ans--;
  }
  cout << ans << '\n';
  return 0;
}
