#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, ans = 0;
  cin >> n;
  vector<long long> p(n, 0);
  for (long long(i) = 0; (i) < (n); ++(i)) cin >> p[i];
  long long pos = 0, ord = 0;
  while (pos < n) {
    if (p[pos] == pos + 1) {
      ord++;
      while (pos + 1 < n && p[pos + 1] == pos + 1 + 1) {
        pos++;
        ord++;
      }
      if (ord == 1)
        ans++;
      else
        ans += ord - 1;
      ord = 0;
    }
    pos++;
  }
  cout << (ans) << endl;
  return 0;
}
