#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
  int n, cnt = 0;
  cin >> n;
  vector<int> arr(n), ar(n), v;
  ;
  iota(ar.begin(), ar.end(), 1);
  for (int i = 0; i < (int)(n); i++) cin >> arr[i];
  for (int i = 0; i < (int)(n); i++) {
    if (ar[i] == arr[i]) v.push_back(i + 1);
  }
  for (int i = 0; i < v.size(); i += 2) {
    cnt += v[i + 1] - v[i];
  }
  if (v.size() % 2 == 1) cnt++;
  cout << cnt << endl;
  return 0;
}
