#include <bits/stdc++.h>
using namespace std;
const long long INF = LONG_LONG_MAX;
const long long MINF = -10e10;
const int mod = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> nums(n);
  for (int i = 0; i < (n); ++i) {
    cin >> nums[i];
  }
  int ans = 0;
  bool active = false;
  for (int i = 0; i < n - 2; i++) {
    if (nums[i] == (i + 1) && (!active)) {
      active = true;
      ans++;
    } else {
      active = false;
    }
  }
  if (!active && nums[n - 1] == (n)) {
    ans++;
  }
  cout << ans << endl;
}
