#include <bits/stdc++.h>
using namespace std;
long long i, j, k, n, tab[100010];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> tab[i];
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    if (tab[i] != i) continue;
    int hitung = 0;
    while (tab[i] == i && i <= n) {
      hitung++;
      i++;
    }
    if (hitung == 1)
      ans += 1;
    else if (hitung <= 3)
      ans += hitung - 1;
    else
      ans += hitung - 2;
  }
  cout << ans << "\n";
}
