#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& a) {
  return os << "(" << a.first << "," << a.second << ")";
}
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << (*i) << " ";
  cout << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
int nextInt() {
  int x;
  scanf("%d", &x);
  return x;
}
long long nextLong() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int main2() {
  int N = nextInt();
  vector<int> b(N);
  for (int i = 0, _n = (int)(N); i < _n; ++i) {
    int a = nextInt() - 1;
    b[i] = i == a ? 1 : 0;
  }
  vector<int> lens;
  int len = 0;
  for (int i = 0, _n = (int)(N); i < _n; ++i) {
    if (b[i]) {
      len++;
    } else {
      if (len > 0) lens.push_back(len);
      len = 0;
    }
  }
  if (len > 0) lens.push_back(len);
  int ans = 0;
  for (int len : lens) {
    ans += max(1, len - 1);
  }
  cout << ans << endl;
  return 0;
}
int main() {
  main2();
  return 0;
}
