#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bitset<100000> b;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p, p--;
    b[i] = i != p;
  }
  int ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    if (b[i] && b[i + 1]) continue;
    b[i] = b[i + 1] = true;
    ans++;
  }
  cout << ans << endl;
}
