#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<int> p;
  for (int i = 0; i < N; ++i) {
    int p_;
    cin >> p_;
    p.push_back(p_ - 1);
  }
  int single_same = 0;
  int double_same = 0;
  int flag = 0;
  for (int i = 0; i < N; ++i) {
    if (flag == 0 && p[i] == i) {
      single_same++;
      flag = 1;
    } else if (flag == 1 && p[i] == i) {
      double_same++;
      flag = 0;
    }
  }
  cout << single_same << endl;
  return 0;
}
