#include <bits/stdc++.h>
using namespace std;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  while (b != 0) {
    auto na = a % b;
    a = b;
    b = na;
  }
  return a;
}
void oneCase() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto& el : p) {
    cin >> el;
    --el;
  }
  int cnt = 0;
  int i = 0;
  while (i < n) {
    int cur = 0;
    while (i < n && p[i] == i) {
      ++i;
      ++cur;
    }
    if (cur > 0) {
      cnt += max(cur - 1, 1);
    }
    ++i;
  }
  cout << cnt << '\n';
}
int main() {
  int t = 1;
  while (t--) {
    oneCase();
  }
  return 0;
}
long long fact(long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    res = (res * n) % mod;
    --n;
  }
  return res;
}
