#include <bits/stdc++.h>
using namespace std;
int number[100005];
int main() {
  int N, min_count = 0, flag = 0, small_idx;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> number[i];
  }
  for (int i = 0; i < N; i++) {
    if (number[i] == i + 1 && flag == 0) {
      flag = 1;
      small_idx = i;
    } else if (number[i] == i + 1 && flag == 1) {
      flag = 0;
      min_count += i - small_idx;
    }
  }
  if (flag) min_count++;
  cout << min_count << endl;
  return 0;
}
