#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t = 0, w = 0;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = -99999;
  for (int i = 1; i <= n; i++) {
    if (i == a[i]) t++;
    if (w + 1 <= i && a[i - 1] == i - 1 && a[i] == i) {
      w = i;
      t--;
    }
  }
  cout << t << endl;
  return 0;
}
