#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
int n;
vector<int> d;
void input() {
  cin >> n;
  d.resize(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  return;
}
lint solve() {
  int cnt = 0;
  int ans = 0;
  bool h = true;
  for (int i = 0; i < n; i++) {
    if (d[i] == i + 1) {
      if (cnt == 0) {
        cnt++;
        h = true;
      } else
        cnt++;
    } else {
      h = false;
      if (cnt == 1) ans++;
      if (cnt > 1) ans += cnt - 1;
      cnt = 0;
    }
    if (i == n - 1 && h == true) {
      if (cnt == 1)
        ans++;
      else
        ans += cnt - 1;
    }
  }
  return ans;
}
int main(void) {
  input();
  printf("%lld\n", solve());
  return 0;
}
