#include <bits/stdc++.h>
using namespace std;
int a[100003];
int main() {
  int n, b = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == i + 1) b++;
  }
  if (b == 0) {
    cout << b;
    return 0;
  }
  if (b >= n - b)
    cout << (b + 1) / 2;
  else
    cout << b / 2 + 1;
  system("pause");
  return 0;
}
