#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
int main() {
  int n, cnt = 0, j = 0;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  while (j < n - 1) {
    if (p[j] != j + 1) break;
    swap(p[j], p[j + 1]);
    cnt++;
    j++;
  }
  for (int i = j + 1; i < n; i++) {
    if (p[i] == i + 1) {
      cnt++;
      swap(p[i], p[i - 1]);
    }
  }
  cout << cnt << endl;
}
