#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int paircount = 0;
  int singlecount = 0;
  for (int i = 0; i < n; ++i) {
    int j = i + 1;
    if (i != n - 1 && arr[j] == j + 1 && arr[i] == i + 1) {
      paircount++;
      i++;
    } else if (i != n - 1 && arr[i] == i + 1 && arr[j] != j + 1) {
      singlecount++;
    } else if (i == n - 1 && arr[i] == i + 1) {
      singlecount++;
      cout << "last element fault \n ";
    }
  }
  int total = paircount + singlecount;
  cout << total;
  return 0;
}
