#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  cerr << " " << h;
  if (sizeof...(t) > 0) cerr << " :";
  debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
  for (size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
ll ctoi(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}
bool pairCompare(const pll firstElof, pll secondElof) {
  return firstElof.first > secondElof.first;
}
ll i, j, k, l;
ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007;
ll INF = 1LL << 60;
ll ans = 0;
ll z = 0, o = 1;
vl flag, color, D;
vll path;
int main() {
  cin >> N;
  vl P(N);
  for (i = 0; i < N; i++) cin >> P[i];
  vl Q = P;
  for (i = 0; i < N - 1; i++) {
    if (P[i] == i + 1) {
      swap(P[i], P[i + 1]);
      ans++;
    }
  }
  ll pre = 0;
  for (i = N - 1; i >= 1; i--) {
    if (Q[i] == i + 1) {
      swap(Q[i], Q[i - 1]);
      pre++;
    }
  }
  ans = min(ans, pre);
  cout << ans;
}
