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