#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, val, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> val;
    if (val == i) cnt++;
  }
  if (cnt > 1) cnt--;
  cout << cnt;
  return 0;
}
