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