#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}
long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }
const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int i = 0;
  long long ans = 0;
  while (true) {
    if (i > n) break;
    int cnt = 0;
    if (a[i] == i + 1) {
      while (a[i] == i + 1) {
        cnt++;
        i++;
      }
      if (cnt == 1) {
        ans += 1;
      } else {
        ans += cnt / 2;
      }
    }
    i++;
  }
  cout << ans;
}
