#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    if (i == arr[i]) {
      int j = i;
      while (arr[j] == j) {
        j++;
        ans++;
      }
      if (j > i + 1) ans--;
      i = j - 1;
    }
  }
  cout << ans << endl;
}
