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