#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long p;
  long long out = 0;
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> p;
    if (p == i + 1) out++;
  }
  if (out > 1) out--;
  cout << out << endl;
  return 0;
}
