#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, k, n, a[100010], flg[100010] = {0}, cnt, c;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == a[i]) flg[i] = 1;
  }
  cnt = c = 0;
  for (i = 1; i <= n; i++) {
    if (flg[i] == 1)
      c++;
    else if (c > 1 && c % 2 == 0)
      cnt += c / 2, c = 0;
    else if (c > 1)
      cnt += c - 1, c = 0;
    else
      cnt += c, c = 0;
  }
  if (c > 1)
    cnt += c - 1;
  else if (c > 0)
    cnt++;
  cout << cnt << endl;
}
