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