#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n];
  int same = 0;
  int twins = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    if (i + 1 == p[i]) {
      same++;
    }
  }
  if (p[0] == 1 && p[1] == 2) {
    twins++;
  }
  if (p[n - 2] == n - 1 && p[n - 1] == n) {
    twins++;
  }
  for (int i = 1; i < n - 1; i++) {
    if ((p[i - 1] == i && p[i] == i + 1) ||
        (p[i] == i + 1 && p[i + 1] == i + 2)) {
      twins++;
    }
  }
  cout << same - twins + (twins + 1) / 2 << endl;
}
