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