#include <bits/stdc++.h>
using namespace std;
constexpr int Inf = 1000000000;
constexpr long long INF = 1e18;
constexpr long long MOD = 1000000007;
const double PI = 3.1415926535897;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int ret = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == i + 1) {
      cnt++;
    } else {
      if (cnt == 0) {
        ret = ret;
      } else if (cnt == 1) {
        ret++;
      } else {
        ret += cnt - 1;
      }
      cnt = 0;
    }
  }
  if (cnt == 0) {
    ret = ret;
  } else if (cnt == 1) {
    ret++;
  } else {
    ret += cnt - 1;
  }
  cnt = 0;
  cout << ret << endl;
}
