#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long MAXN = 1e5 + 5;
const long long N = 1e5 + 5;
long long fac[N];
long long spf[MAXN];
void pre(long long p) {
  fac[0] = 1;
  for (long long i = 1; i < N; i++) {
    fac[i] = (fac[i - 1] * i) % p;
  }
}
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < MAXN; i++) spf[i] = i;
  for (long long i = 4; i < MAXN; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < MAXN; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
vector<long long> getFactorization(long long x) {
  vector<long long> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
unsigned long long power(unsigned long long x, long long y, long long p) {
  unsigned long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
unsigned long long modInverse(unsigned long long n, long long p) {
  return power(n, p - 2, p);
}
unsigned long long nCr(unsigned long long n, long long r, long long p) {
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void solve(long long TC) {
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 0; i < n; i++) cin >> a[i + 1];
  long long ans = 0;
  long long i = 1;
  while (i <= n) {
    if (a[i] == i) {
      long long cnt = 0;
      while (i <= n && a[i] == i) {
        i++;
        cnt++;
      }
      ans += max(1LL, cnt - 1);
    } else {
      i++;
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  long long T = 1;
  for (long long i = 1; i <= T; i++) {
    solve(i);
  }
  return 0;
}
