#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long c, long long d) { return c / gcd(c, d) * d; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    return b;
  }
  return a;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> p(n);
  for (long long i = 0; i < (n); i++) {
    cin >> p[i];
  }
  long long count = 0;
  bool both = false;
  for (long long i = 0; i < (n - 1); i++) {
    if (p[i] == i + 1 || p[i + 1] == i + 2) {
      if (p[i] == i + 1 && p[i + 1] == i + 2) both = true;
      swap(p[i], p[i + 1]);
      count++;
      if (both) i++;
    }
    if (p[n - 1] == n && n % 2 == 1) {
      swap(p[n - 1], p[n - 2]);
      count++;
    }
    both = false;
  }
  cout << count << endl;
  return 0;
}
