#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;
long long N, M, K;
vector<long long> A, B;
string S, T;
void input() {
  long long x, y, z;
  cin >> N;
  A.resize(N);
  for (long long i = (long long)(0); i <= (long long)(N - 1); ++i) {
    long long x;
    cin >> x;
    A[i] = x - 1;
  };
}
void solve() {
  long long cnt = 0;
  for (long long i = (long long)(0); i <= (long long)(N - 1); ++i) {
    if (i == A[i]) cnt++;
  }
  cout << min(0LL, cnt - 1) << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}
