#include <bits/stdc++.h>
using namespace std;
map<string, int> sad;
int a[100005];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, cnt = 0, mx = 0;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> m;
    if (m == i) {
      cnt++;
    }
  }
  if (cnt == n) {
    cout << cnt - 1 << "\n";
    return 0;
  }
  cout << cnt << "\n";
  return 0;
}
