#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<ll> t;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    if (i + 1 == p[i]) {
      cnt++;
    } else if (i > 0 && i == p[i - 1]) {
      ans += max(1, cnt - 1);
      cnt = 0;
    }
  }
  if (cnt) ans += max(1, cnt - 1);
  cout << ans << endl;
  return 0;
}
