#include <bits/stdc++.h>
using namespace std;
int vis[100005];
int x[100005];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(vis, 0, sizeof(vis));
    int i, k;
    for (i = 1; i <= n; i++) {
      scanf("%d", &x[i]);
      if (x[i] == i) vis[i] = 1;
    }
    int ans = 0;
    for (i = 1; i < n; i++) {
      if (vis[i] && vis[i + 1]) {
        ans++;
        i++;
      } else if (vis[i]) {
        for (k = i + 1; k <= n; k++) {
          if (x[i] != k) break;
        }
        ans += (k - i);
        i += (k - i);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
