#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
const ll INF = 1 << 29;
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  vector<bool> b(N, true);
  int count = 0;
  for (int i = 0; i < int(N); i++) {
    cin >> p[i];
    if (p[i] == i + 1) {
      b[i] = false;
      count++;
    }
  }
  for (int i = 0; i < int(N - 1); i++)
    if ((!b[i]) && (!b[i + 1])) count--;
  cout << count << endl;
  return 0;
}
