#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100005];
  int n;
  scanf("%d", &n);
  int num = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == i) num++;
  }
  if (num % 2 == 1)
    printf("%d\n", (num - 3) / 2 + 3);
  else
    printf("%d\n", num / 2);
  return 0;
}
