#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) cin >> p[i];
  vector<char> mark(N);
  for (int i = 0; i < N; ++i) {
    if (p[i] == i + 1)
      mark[i] = 'x';
    else
      mark[i] = 'o';
  }
  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (mark[i] == 'x' && mark[i + 1] == 'x') {
      ans += 1;
      mark[i] = 'o';
      mark[i + 1] = 'o';
    } else if (mark[i] == 'o' && mark[i + 1] == 'x') {
      ans += 1;
      mark[i] = 'o';
      mark[i + 1] = 'o';
    } else if (mark[i] == 'x' && mark[i + 1] == 'o') {
      ans += 1;
      mark[i] = 'o';
      mark[i + 1] = 'o';
    }
  }
  cout << ans << endl;
  return 0;
}
