#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &v : a) {
    cin >> v;
    --v;
  }
  auto b = a;
  for (int i = 0; i < n - 1;)
    if (a[i] == i || a[i + 1] == i + 1) {
      swap(a[i], a[i + 1]);
      ++ans;
      i += 2;
    } else
      ++i;
  if (a[n - 1] == n - 1) ++ans;
  int nans = 0;
  for (int i = n - 1; i > 0;)
    if (b[i] == i || b[i - 1] == i - 1) {
      swap(b[i], b[i - 1]);
      i -= 2;
      ++nans;
    } else
      --i;
  if (b[0] == 0) ++nans;
  cout << min(ans, nans) << endl;
}
