#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int x = 1, t = 0, ans = 0;
  while (x < n + 1) {
    if (a[x] == x) t++;
    if (a[x] != x) {
      if (t != 0) ans += (t + 1) / 2;
      t = 0;
    }
    x++;
  }
  cout << ans;
}
