#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
long long A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
long long ans = 0;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
int intceil(int a, int b) { return (a + (b - 1)) / b; }
signed main() {
  cin >> N;
  vector<int> p(N);
  cin >> p;
  for (int i = 0; i < (int)(N); i++) {
    if (p[i] == i + 1) {
      ans++;
    }
  }
  ans = intceil(ans, 2);
  cout << ans << "\n";
}
