#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll << 60;
int main(int argc, char **argv) {
  ll N;
  cin >> N;
  vector<bool> m(N);
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    m[i] = (i == (a - 1));
  }
  ll res{0};
  ll j;
  for (ll i = 0; i < N;) {
    j = i + 1;
    if (m[i]) {
      ll tmp{1};
      for (; j < N; ++j) {
        if (!m[j]) break;
        ++tmp;
      }
      res += max(1ll, tmp - 1);
    }
    i = j;
  }
  std::cout << res << std::endl;
}
