#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000;
long long N;
long long log;
long long counter = 0;
vector<long long> distances;
int main() {
  scanf("%lld", &N);
  long long log = -1;
  for (int i = 0; i < N; ++i) {
    long long pi;
    scanf("%lld", &pi);
    if (pi == i + 1) {
      if (log != -1) distances.push_back(i - log);
      log = i;
    }
  }
  long long ans = 0;
  if (distances.size() != 0) {
    for (int i = 0; i < distances.size(); ++i) {
      if (i % 2 == 1) continue;
      ans += distances[i];
    }
  }
  printf("%lld\n", ans);
}
