#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  int p = 0;
  int d = 0;
  for (long long i = 0; i < (n); i++) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    if (tmp == i + 1) d++;
    if (i != 0) {
      if (tmp == i + 1 && v[i - 1] == i) p++;
    }
  }
  cout << d - p << endl;
  return 0;
}
