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