#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vvin = vector<vin>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vst = vector<string>;
using P = pair<ll, ll>;
const int inf = 1e9 + 7;
const ll INF = 9e18;
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T>
inline void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vin a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (a[i] == i + 1) ans++;
  }
  cout << (ans + 1) / 2 << endl;
}
