#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> p[i];
    p[i]--;
  }
  vector<int> diff(n);
  for (int i = 0; i < (int)(n); i++) {
    diff[i] = p[i] - i;
  }
  int ans = 0;
  int right = 0;
  while (right < n) {
    if (diff[right] != 0) {
      right++;
      continue;
    }
    int cnt = 1;
    right++;
    while (right < n) {
      if (diff[right] != 0) break;
      right++;
      cnt++;
    }
    if (cnt == 1)
      ans += 1;
    else
      ans += cnt - 1;
  }
  cout << ans << endl;
}
