#include <bits/stdc++.h>
using namespace std;
int P[114514];
int main() {
  int N;
  int ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    if (P[i] == i + 1) {
      int l = i;
      while (P[i] == i + 1) {
        i++;
      }
      int len = i - l;
      if (len == 1) {
        ans++;
      } else {
        ans += len - 1;
      }
    }
  }
  cout << ans << endl;
}
