#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e9 + 7;
long long int int_pow(long long int base, long long int exp) {
  long long int result = 1;
  while (exp) {
    if (exp & 1) result *= base;
    exp /= 2;
    base *= base;
  }
  return result;
}
long long int a[1000000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, j = 0, ans = 0;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i], a[i]--;
  for (long long int i = 0; i < n; i++) {
    if (a[i] == i) {
      j = i + 1;
      if (j >= n - 1) j = i - 1;
      swap(a[i], a[j]);
      ans++;
    }
  }
  cout << ans;
}
