#include <bits/stdc++.h>
using namespace std;
signed main() {
  int64_t N;
  cin >> N;
  vector<int64_t> p(N + 1);
  for (int64_t i = (1); i < (N + 1); i++) {
    cin >> p[i];
  }
  vector<int64_t> v;
  int64_t k = 0;
  for (int64_t i = (1); i < (N + 1); i++) {
    if (p[i] == i) {
      k++;
    } else {
      if (k > 0) {
        v.push_back(k);
      }
      k = 0;
    }
  }
  if (k > 0) {
    v.push_back(k);
  }
  int64_t ans = 0;
  for (auto e : v) {
    if (e == 1)
      ans++;
    else
      ans += e - 1;
  }
  cout << ans << endl;
  return 0;
}
