#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, co = 0, d = 1, i = 0;
  cin >> N;
  vector<long long> p(N);
  vector<long long> c(0);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
    if (i + 1 == p.at(i)) c.push_back(i);
  }
  while (i < (long long)c.size() - 1) {
    if (c.at(i + 1) - c.at(i) == 1) {
      i++;
      if (i + 1 != c.size()) {
        if (c.at(i + 1) - c.at(i) == 1) {
          while (i + 1 != c.size() && c.at(i + 1) - c.at(i) == 1) {
            d++;
            i++;
          }
          d++;
          d /= 2;
          co += d;
        }
      } else {
        co++;
      }
    }
    d = 1;
    i++;
  }
  cout << (long long)c.size() - co << endl;
}
