#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const int max_n = 100005;
int arr[max_n + 1];
int state[max_n + 1];
int last[max_n + 1];
int main(void) {
  int n;
  int i;
  int nb_perm = 0;
  scanf("%d\n", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
    if (arr[i] == (i + 1)) state[i] = 1;
  }
  int j = -1;
  for (i = n - 1; i >= 0; --i) {
    last[i] = j;
    if (state[i] == 1) j = i;
  }
  for (i = 0; i < n; ++i) {
    if (state[i] == 1) {
      int next = last[i];
      if (next == -1) {
        ++nb_perm;
        break;
      }
      int nb_to_move = 1;
      if (state[next] == 1) ++nb_to_move;
      int dist = next - i;
      if (dist == 1)
        ++nb_perm;
      else
        nb_perm += nb_to_move;
      state[i] = 2;
      state[next] = 2;
    }
  }
  printf("%d\n", nb_perm);
  return 0;
}
