#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[114514];
  int ans = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n - 2; i++) {
    if (a[i] == i && a[i + 1] == i + 1) {
      ans++;
      i = i + 2;
      continue;
    }
    if (a[i] == i) ans++;
  }
  if (a[n - 1] == n && a[n] == n)
    ans++;
  else if (a[n - 1] == n - 1 || a[n] == n)
    ans++;
  cout << ans << endl;
  return 0;
}
