#include <bits/stdc++.h>
using namespace std;
int n, a[1000000], ans = 0;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == i) ans++;
  }
  if (ans == 0)
    cout << 0;
  else if (ans == 1)
    cout << 1;
  else
    cout << ans - 1;
}
