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