#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<bool> a(n, false);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    if (i + 1 != p[i]) a[i] = true;
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] && a[i + 1]) {
    } else if (!a[i] && !a[i + 1]) {
      a[i] = true;
      a[i + 1] = true;
      ans++;
      i++;
    } else {
      a[i] = true;
      a[i + 1] = true;
      ans++;
    }
  }
  if (!a[n - 1]) ans++;
  cout << ans << endl;
}
