#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> p;
  int same_cnt = 0;
  int same_streak_cnt = 0;
  bool streak = false;
  bool set = false;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int _p;
    cin >> _p;
    p.push_back(_p);
    if (streak && i + 1 == _p && !set) {
      same_cnt += 1;
      same_streak_cnt += 1;
      set = true;
    } else if (i + 1 == _p) {
      same_cnt += 1;
      streak = true;
    } else {
      streak = false;
      set = false;
    }
  }
  int ans = same_cnt - same_streak_cnt;
  cout << ans << endl;
}
