#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;
int main() {
  int n;
  cin >> n;
  long long arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  int t = 0;
  vector<int> v;
  for (int i = 0; i < n - 1; i++) {
    if (arr[i] == i + 1) {
      if (v.size() != 0) {
        swap(arr[i], arr[t]);
        t++;
      } else
        swap(arr[i], arr[i + 1]);
      ans++;
    } else
      v.push_back(i);
  }
  cout << ans << '\n';
  return 0;
}
