#include <bits/stdc++.h>
using namespace std;
long long ans, cnt;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> p(N + 1);
  for (long long i = 1; i < (long long)(N + 1); ++i) {
    cin >> p[i];
  }
  int right = 1;
  int left = 1;
  for (int i = 1; i <= N; i++) {
    if (p[i] == i) {
      if (right != i - 1) {
        ans++;
        right = i;
        left = i;
      } else {
        right = i;
        if (right - left != 1) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
