#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int sw = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int num;
    cin >> num;
    if (num == i) {
      ++sw;
    }
  }
  if (sw % 2 == 0) {
    cout << sw / 2 << endl;
  } else {
    cout << sw / 2 + 1 << endl;
  }
  return 0;
}
