#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int main() {
  int i, j, m, n, k;
  cin >> m;
  int count = 0;
  for (i = 1; i <= m; i++) {
    cin >> a[i];
    if (a[i] == i) {
      b[count++] = i;
    }
  }
  if (count == 0) {
    cout << 0 << endl;
    return 0;
  }
  j = 0;
  if (count & 1) j = 1;
  for (i = 0; i < count; i++) {
    if (i == count - 1) {
      if (b[count - 1] - 1 != b[count - 2]) j++;
      break;
    }
    if (b[i] + 1 == b[i + 1]) {
      j++;
      i++;
    } else
      j++;
  }
  cout << j << endl;
  return 0;
}
