#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 = 1;
  k = 1;
  int s = 0;
  for (i = 0; i < count; i++) {
    if (b[i] + 1 == b[i + 1]) {
      k++;
      j = k;
    } else
      k = 1;
    if (k == 1) {
      if (j & 1)
        s += (j + 1) / 2;
      else
        s += j / 2;
    }
  }
  cout << s << endl;
  return 0;
}
