#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[100000], ans, num;
bool match[100000], p_near[100000], m_near[100000];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
    if (p[i] == i) {
      match[i] = true;
    }
    if (i - p[i] == 1) {
      m_near[i] = true;
    }
    if (i - p[i] == -1) {
      p_near[i] = true;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (match[i]) {
      if (m_near[i] == true && p_near[i] == true) {
        num++;
      }
      if (match[i + 1]) {
        match[i + 1] = false;
      }
      num++;
    }
  }
  cout << num << endl;
  return 0;
}
