#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
long long gcd(long long x, long long y) {
  if (x % y == 0) return y;
  return gcd(y, x % y);
}
int main(void) {
  int n, ans = 0, l;
  cin >> n;
  bool can = false;
  for (int i = 1; i < (int)n + 1; ++i) {
    int a;
    cin >> a;
    if (a == i) {
      if (can) {
        can = false;
        ans += i - l;
        continue;
      }
      l = i;
      can = true;
    }
  }
  cout << ans << endl;
  return 0;
}
