#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int n;
long long a[100005] = {0};
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[1] == i) ans++;
  }
  if (ans == 0) {
    cout << 0;
    return 0;
  }
  ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == i || a[i + 1] == i) {
      ans++;
      swap(a[i], a[i + 1]);
    }
  }
  cout << ans;
}
