#include <bits/stdc++.h>
using namespace std;
int max(int x, int y) {
  if (x > y) return x;
  return y;
}
int abs(int x) {
  if (x < 0) {
    return -x;
  }
  return x;
}
int N, p[100001], ans, num;
bool match[100001];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
    if (p[i] == i) {
      match[i] = true;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (match[i]) {
      if (match[i + 1]) {
        i++;
      }
      num++;
    }
  }
  if (match[N]) {
    num++;
  }
  cout << num << endl;
  return 0;
}
