#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int p[100000], num[100000] = {}, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    if (i + 1 == p[i]) num[i] = 1;
  }
  for (int i = 0; i < N; i++) {
    if (i == 0 && num[i] == 1) {
      if (num[i + 1] == 0) ans++;
    } else if (num[i] == 1) {
      if (num[i - 1] == 0 && num[i + 1] == 0) ans++;
      if (num[i - 1] == 1 && num[i + 1] == 0) ans++;
      if (num[i - 1] == 1 && num[i + 1] == 1) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
