#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1LL << 60;
const int INF = 1001001001;
const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> pair<int, int>(n);
  for (int i = 0; i < (n); i++) {
    cin >> pair<int, int>[i];
  }
  long long ans = 0;
  for (int i = 1; i <= (n); i++) {
    if (i == pair<int, int>[i - 1]) {
      long long cnt = 0;
      while (i++ < n && i++ != pair<int, int>[i]) {
        i++;
        cnt++;
      }
      ans += cnt;
    }
  }
  cout << ans << endl;
  return 0;
}
