#include <bits/stdc++.h>
using namespace std;
int a[100005];
bool v[100005];
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == i)
      v[i] = false;
    else
      v[i] = true;
  }
  for (int i = 1; i < n; i++) {
    if (v[i] == false && v[i + 1] == false) {
      ans++;
      v[i] = v[i + 1] = true;
    }
  }
  for (int i = 1; i < n; i++) {
    if (v[i] == false) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
