#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int calc(int length) {
  if (length <= 1) return length;
  return length - 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) cin >> p[i];
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (p[i] == i)
      cnt[i] = 1;
    else
      cnt[i] = 0;
  }
  int ans = 0, length = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > 0) {
      length++;
    } else {
      ans += calc(length);
      length = 0;
    }
  }
  ans += calc(length);
  cout << ans << endl;
  return 0;
}
