#include <bits/stdc++.h>
using namespace std;
bool OK(vector<bool> n) {
  bool ans = true;
  for (int i = 0; i < n.size(); i++) ans &= n[i];
  return ans;
}
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    int v;
    cin >> v;
    v--;
    p[i] = v;
  }
  vector<bool> check(N, false);
  for (int i = 0; i < N; i++) {
    if (p[i] != i) check[i] = true;
  }
  int cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    if (check[i] == false) {
      swap(p[i], p[i + 1]);
      cnt++;
      check[i] = check[i + 1] = true;
      if (OK(check)) break;
    }
  }
  cout << cnt << endl;
  return 0;
}
