#include <bits/stdc++.h>
using namespace std;
int N, ope = 0;
vector<int> p(100002, 0);
vector<bool> visited(100001, false);
int calc(int i) {
  if (visited[i]) return 0;
  visited[i] = true;
  if (p[i] != i || i == N) {
    return 0;
  } else {
    return calc(i + 1) + 1;
  }
}
int main() {
  cin >> N;
  for (int i = (1); i < (N + 1); i++) {
    cin >> p[i];
  }
  for (int i = (1); i < (N + 1); i++) {
    int c = calc(i);
    if (c > 0) ope += max(1, c - 1);
  }
  cout << ope << endl;
  return 0;
}
