#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
bool s[maxn];
int pre[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == i)
      s[i] = true;
    else
      s[i] = false;
  }
  if (s[1])
    pre[1] = 1;
  else
    pre[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (s[i])
      pre[i] = pre[i - 1] + 1;
    else
      pre[i] = 0;
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (!pre[i] || pre[i] < pre[i + 1])
      continue;
    else {
      if (pre[i] == 1)
        ans += 1;
      else
        ans += pre[i] - 1;
    }
  }
  if (pre[n]) {
    if (pre[n] == 1)
      ans += 1;
    else
      ans += pre[n] - 1;
  }
  printf("%d\n", ans);
  return 0;
}
