#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> p(n, 0), dis(n, 0);
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> p[i];
    dis[i] = p[i] - (i + 1);
  }
  int cnt = 0;
  int zero_cnt = 0;
  for (int(i) = (0); (i) < (n); (i)++) {
    if (dis[i] == 0) {
      zero_cnt++;
    } else {
      if (zero_cnt > 1)
        cnt += (zero_cnt - 1);
      else if (zero_cnt == 1)
        cnt += 1;
      zero_cnt = 0;
    }
  }
  if (zero_cnt > 1)
    cnt += (zero_cnt - 1);
  else if (zero_cnt == 1)
    cnt += 1;
  cout << cnt << endl;
  return 0;
}
