#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
int cnt[N], vis[N];
int main() {
  int n, x;
  while (~scanf("%d", &n)) {
    memset(cnt, 0, sizeof(cnt));
    memset(vis, 0, sizeof(vis));
    bool flag = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      if (x == i) vis[i] = i;
    }
    int p = 0, tmp = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == i) {
        cnt[p++] = vis[i];
        tmp++;
      }
    }
    for (int i = 0; i < p; i++) {
      if (p >= 2 && i + 1 < p && cnt[i] + 1 == cnt[i + 1]) {
        while (i + 1 < p && cnt[i] + 1 == cnt[i + 1]) i++;
        tmp--;
      }
    }
    if (flag)
      printf("%d\n", tmp - 1);
    else
      printf("%d\n", tmp);
  }
  return 0;
}
