#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p[100010], ichi = 0, ni = 0, i = 1;
  cin >> n;
  p[n + 1] = 0;
  while (i <= n) {
    cin >> p[i];
    if (p[i] == i) {
      i++;
      if (p[i] == i)
        ni++;
      else
        ichi++;
      i++;
    } else
      i++;
  }
  cout << ichi + ni;
  return 0;
}
