#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > count_runlength(int* a, int* b) {
  vector<pair<int, int> > v;
  int p = *a;
  int l = 0;
  while (1) {
    a++;
    l++;
    if (a == b) break;
    if (p != *a) {
      v.push_back(pair<int, int>(p, l));
      l = 0;
      p = *a;
    }
  }
  v.push_back(pair<int, int>(p, l));
  return v;
}
int main() {
  int N;
  int p[100001];
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
    if (p[i] == i)
      p[i] = 1;
    else
      p[i] = 0;
  }
  int result = 0;
  auto v = count_runlength(p + 1, p + 100001);
  for (auto i = v.begin(); i != v.end(); i++) {
    if (i->first == 1) result += (i->second + 1) / 2;
  }
  cout << result << endl;
  return 0;
}
