#include <bits/stdc++.h>
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    v.push_back(t);
  }
  int ans = 0, same = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] == i + 1) {
      same++;
    } else if (same == 1) {
      ans += 1;
      same = 0;
    } else if (same > 1) {
      ans += same - 1;
      same = 0;
    }
    if (i == n - 1) {
      if (same == 1) {
        ans += 1;
      } else if (same > 1) {
        ans += same - 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
