#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(n); i++) {
    if (a[i] == i + 1)
      a[i] = 1;
    else
      a[i] = 0;
  }
  int id = 0;
  int res = 0;
  while (1) {
    int cnt = 0;
    while (a[id] == 1) {
      cnt++;
      id++;
      if (id == n) break;
    }
    if (cnt == 1)
      res += cnt;
    else if (cnt > 1)
      res += cnt - 1;
    if (id == n) break;
    while (a[id] == 0) {
      id++;
      if (id == n) break;
    }
    if (id == n) break;
  }
  cout << res << endl;
  return 0;
}
