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