#include <bits/stdc++.h>
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a, ul b) { return b ? gcd(b, a % b) : a; }
int main() {
  int n, ans = 0, seq = 0;
  cin >> n;
  int a;
  for (li i = 0; i < (n); i++) {
    cin >> a;
    if (a == i + 1)
      seq++;
    else if (seq)
      seq = 0, ans += max(1, seq - 1);
  }
  if (seq) ans += max(1, seq - 1);
  cout << ans << endl;
  return 0;
}
