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