#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;
const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);
vector<bool> v;
int dfs(const vi &p, int i) {
  if (i == p.size()) return 0;
  v[i] = false;
  if (p[i] == i) {
    return dfs(p, i + 1) + 1;
  }
}
int main() {
  int n;
  cin >> n;
  vi p(n);
  for (int i = 0; i < (n); ++i) {
    int t;
    cin >> t;
    p[i] = t - 1;
  }
  int ans = 0;
  v.resize(n, true);
  for (int i = 0; i < n; i++) {
    if (v[i]) {
      int res = dfs(p, i);
      ans += res <= 1 ? res : res - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
