#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<long long int>;
const int MOD = 1e9 + 7;
vi alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
               'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int main() {
  int N;
  cin >> N;
  vi p(N);
  vector<bool> q(N, false);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    if (p[i] != i + 1) q[i] = true;
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (q[i] == false && i != N - 1) {
      bool x = q[i];
      q[i] = q[i + 1];
      q[i + 1] = x;
      count++;
    } else if (q[i] == false && i == N - 1) {
      bool x = q[N - 1];
      q[N - 1] = q[N - 2];
      q[N - 2] = x;
    }
  }
  cout << count << endl;
}
