#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> p(N + 1);
  for (int i = 1; i <= N; ++i) cin >> p[i];
  long long ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (p[i] != i) continue;
    if (i + 1 <= N && p[i + 1] != i) {
      swap(p[i], p[i + 1]);
      ++ans;
    } else if (i + 1 < N && p[i + 1] == i) {
      swap(p[i + 1], p[i + 2]);
      swap(p[i], p[i + 1]);
      ++ans;
    }
  }
  cout << ans << endl;
}
