#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int n;
int ar[100010], ar2[100010];
int ans1 = 0, ans2 = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
    ar2[i] = ar[i];
  }
  for (int i = 1; i < n; i++) {
    if (ar[i] == i) {
      ans1++;
      swap(ar[i], ar[i + 1]);
    }
  }
  for (int i = n; i > 1; i--) {
    if (ar2[i] == i) {
      ans2++;
      swap(ar2[i], ar2[i - 1]);
    }
  }
  printf("%d", min(ans1, ans2));
  return 0;
}
