#include <bits/stdc++.h>
using namespace std;
int p[100001], b[100001];
int main() {
  int n, ans = 0;
  cin >> n;
  p[0] = -1;
  for (int i = 1; i < n + 1; i++) {
    cin >> p[i];
    if (p[i] == i) {
      b[i]++;
      if (b[i - 1] == 0) {
        ans++;
      }
    }
    if (b[i - 1] == 1 && p[i - 2] == i) ans++;
  }
  cout << ans << endl;
  return 0;
}
