#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N + 2, 10000000);
  for (int i = 1; i <= N; i++) cin >> a[i];
  int ans = 0;
  bool flg = false;
  for (int left = 1; left <= N; left++) {
    if (a[left] == left) {
      int right = left + 1;
      while (a[right] == right) right++;
      ans += max(1, right - left - 1);
      left = right - 1;
    }
  }
  cout << ans << endl;
}
