#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) cin >> p[i];
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i] == i) {
      int j = 1;
      for (; i + j <= n; j++) {
        if (p[i + j] != i + j) break;
      }
      if (j == 1)
        ans++;
      else
        ans += j - 1;
      i += j - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
