#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> b(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    b[i] = a[i];
  }
  long long int cnt = 0;
  for (long long int i = 0; i < n - 1; i++) {
    if (a[i] == i) {
      swap(a[i], a[i + 1]);
      cnt++;
    }
  }
  long long int cnt2 = 0;
  for (long long int i = n - 1; i > 0; i--) {
    if (b[i] == i) {
      swap(b[i], b[i - 1]);
      cnt2++;
    }
  }
  cout << min(cnt2, cnt) << endl;
  return 0;
}
