#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> p(N + 1);
  p[0] = -1;
  vector<bool> a(N + 1, false);
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
    if (p[i] == i) a[i] = true;
  }
  int tmp = 1;
  int ans = 0;
  while (tmp + 1 <= N) {
    if (a[tmp] && a[tmp + 1]) {
      ans++;
      tmp++;
    } else if (a[tmp]) {
      ans++;
    } else if (a[tmp + 1] && tmp + 1 == N)
      ans++;
    tmp++;
  }
  cout << ans << endl;
}
