#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = (1 << 30) - 1;
const long long INFLL = (1LL << 61) - 1;
const int MOD = 1000000007;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, cnt = 0;
  cin >> N;
  for (int i = (0); i < (N); ++i) {
    int tmp;
    cin >> tmp;
    if (tmp == i + 1) cnt++;
  }
  cout << (cnt + 1) / 2 << endl;
}
