#include <bits/stdc++.h>
using namespace std;
long long n, kq[100010], t = 0, a[100010];
int main() {
  cin >> n;
  for (long i = 1; i <= n; i++) cin >> a[i];
  if (a[1] == 1) kq[1] = 1;
  long cs = 1;
  for (long i = 2; i <= n; i++) {
    if (a[i] == i) {
      if (a[i - 1] == i - 1)
        kq[cs]++;
      else {
        cs++;
        kq[cs]++;
      }
    }
  }
  for (long i = 1; i <= cs; i++)
    if (kq[i] == 1)
      t = t + 1;
    else if (kq[i] > 1)
      t = t + kq[i] - 1;
  cout << t;
  return 0;
}
