#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, x, sum;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == i) sum++;
  }
  if (sum % 2 == 0)
    cout << sum / 2;
  else
    cout << sum / 2 + 1;
  return 0;
}
