#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long LINF = 1LL << 60;
const int INF = 1 << 30;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int i = 0;
  while (i < n) {
    if (i + 1 == a[i]) {
      int j = 0;
      ans += 1;
      while (i + 2 + j == a[i + j + 1]) {
        j++;
      }
      if (j != 0) {
        ans += j - 1;
      }
      i += (j + 1);
    } else {
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}
