#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int a[MAXN];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    a[0] = -1;
    int cnt = 0, t = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == i) {
        cnt++;
      }
    }
    for (int i = 1; i < n; i++) {
      if (a[i + 1] == i + 1 && a[i] == i) t++;
    }
    if (t == cnt - 1)
      printf("%d\n", cnt - 1);
    else
      printf("%d\n", cnt - t);
  }
  return 0;
}
