#include <bits/stdc++.h>
using namespace std;
int n;
int a[100001], po[100001], cnt;
int ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) {
      cnt++;
      po[cnt] = i;
    }
  }
  po[0] = -1;
  for (int i = 1; i <= cnt; i++) {
    int sum = 1;
    while (po[i] == po[i - 1] + 1) {
      i++;
      sum++;
    }
    ans += (sum + 1) / 2;
  }
  if (po[2] == po[1] + 1) ans--;
  cout << ans;
  return 0;
}
