#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int p[N];
  for (int i = (int)0; i < (int)N; i++) {
    cin >> p[i];
    p[i]--;
  }
  long long rsl = 0;
  if (p[0] == 0) {
    swap(p[0], p[1]);
    rsl++;
  }
  for (int i = (int)1; i < (int)N; i++) {
    if (p[i] == i) rsl++;
  }
  cout << rsl << endl;
}
