#include <bits/stdc++.h>
using namespace std;
int n;
int p[105000];
int main() {
  cin >> n;
  int q;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    cin >> q;
    q--;
    if (q == i) a.push_back(i);
  }
  int i = 0;
  int ans = 0;
  if (!a.empty()) {
    while (i < a.size() - 1) {
      if (a[i] == a[i + 1] - 1) {
        ans++;
        i += 2;
      } else {
        ans++;
        i++;
      }
    }
    if (a[a.size() - 1] - a[a.size() - 2] != 1) ans++;
  }
  cout << ans << endl;
  return 0;
}
