#include <bits/stdc++.h>
using namespace std;
bool cmp(long long a, long long b) { return a > b; }
signed main() {
  long long n;
  cin >> n;
  vector<long long> a;
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    if (tmp == i + 1) cnt++;
  }
  if (cnt % 2 == 1) cnt++;
  cout << cnt / 2 << endl;
}
