#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 j = 0; j < n - 1; j++) {
    if (a[j] == true && a[j + 1] == true) {
    } else if ((a[j] == true || a[j + 1] == true) &&
               (a[j] == true && a[j + 1] == true)) {
      a[j] = true;
      a[j + 1] = true;
      ans++;
    } else if (a[j] == false && a[j + 1] == false) {
      a[j] = true;
      a[j + 1] = true;
      ans++;
    }
  }
  cout << ans << endl;
}
