#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int c = 0, flg = 0;
  for (int i = 1; i < n + 1; ++i) {
    int p;
    cin >> p;
    if (p == i) {
      if (flg == 1)
        flg = 2;
      else
        flg = 1;
    } else {
      if (flg == 2) flg = 0;
    }
    if (flg == 1) c++;
  }
  cout << c << endl;
}
