#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]--;
  int l = -1, r = -1;
  for (int i = 0; i < n; i++) {
    if (i != n && p[i] == i) {
      if (l == -1)
        l = i, r = i;
      else
        r++;
    } else {
      if (l != -1) {
        if (r - l <= 1)
          ans++;
        else
          ans += r - l;
        l = r = -1;
      }
    }
  }
  if (l != -1) {
    if (r - l <= 1)
      ans++;
    else
      ans += r - l;
    l = r = -1;
  }
  cout << ans << endl;
  return 0;
}
