#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline bool minimize(T1& a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2>
inline bool maximize(T1& a, T2 b) {
  return a < b && (a = b, 1);
}
template <class T>
void operator>>(istream& ist, vector<T>& vs) {
  for (auto& e : vs) cin >> e;
}
int main() {
  int N;
  cin >> N;
  int p[100001];
  for (int i = 0; i < (int)N; i++) cin >> p[i];
  int sum = 0;
  int prev = -1;
  for (int i = 0; i < (int)N; i++) {
    if (p[i] == i + 1 && prev == -1) {
      prev = i;
    } else if (p[i] == i + 1 && prev >= 0) {
      sum += i - prev;
      prev = -1;
    }
  }
  cout << sum << endl;
}
