#include <bits/stdc++.h>
using namespace std;
int main() {
  bool f = true;
  long long N, ans = 0, cnt;
  cin >> N;
  long long A[N];
  vector<long long> B(N, 0);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    if (i + 1 == A[i]) {
      f = false;
      B[i]++;
    }
  }
  if (f) {
    cout << ans << endl;
    return 0;
  }
  for (long long i = 0; i < N; i++) {
    if (B[i] != 0) {
      f = true;
      cnt = 1;
    }
    if (B[i] != 0 && f) cnt++;
    if (B[i] == 0 && f || i == N - 1 && f) {
      if (cnt != 1) cnt--;
      ans += cnt;
      f = false;
    }
  }
  cout << ans << endl;
}
