#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<bool> B(N, false);
  for (int i = 0; i < (int)(N); i++) {
    cin >> A[i];
    if (A[i] == i + 1) B[i] = true;
  }
  int count = 0;
  int res = 0;
  for (int i = 0; i < (int)(N); i++) {
    if (B[i])
      count++;
    else {
      if (count == 1)
        res++;
      else if (count != 0)
        res += count - 1;
      count = 0;
    }
  }
  if (count == 1)
    res += 1;
  else if (count >= 2)
    res += count - 1;
  cout << res << endl;
}
