#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, count1 = 0, count2 = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }
  for (int i = 0; i < N - 1; i++) {
    if (i == A.at(i) && A.at(i + 1) == i + 1) {
      count1++;
      i++;
    } else if (A.at(i) == i) {
      count2++;
    }
  }
  if (A.at(N - 1) == N - 1) {
    count2++;
  }
  cout << count1 + count2 << endl;
}
