#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int a[N];
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n;) {
    if (a[i] == i) {
      int cnt = 0;
      while (a[i] == i) {
        i++;
        cnt++;
      }
      if (cnt & 1) {
        if (cnt != 1) {
          ans += cnt - 1;
        } else {
          ans += 1;
        }
      } else {
        ans += cnt / 2;
      }
    } else {
      i++;
    }
  }
  printf("%d\n", ans);
}
