#include <bits/stdc++.h>
using namespace std;
int ara[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ara[i];
  int f = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (ara[i] == i) {
      if (f == 0)
        f = 1;
      else {
        if (ara[i - 1] == i - 1)
          ans++;
        else
          ans += 2;
        f = 0;
      }
    }
  }
  if (f == 1) ans++;
  cout << ans << endl;
}
