#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000;
vector<int> v;
int main(int argc, char const *argv[]) {
  int n;
  while (cin >> n) {
    v.clear();
    int x;
    for (int i = 1; i <= n; ++i) {
      cin >> x;
      if (x == i) v.push_back(i);
    }
    int lens = v.size();
    int ans = 0;
    int idx = v[0];
    for (int i = 0; i < lens - 1; ++i) {
      if (v[i] + 1 == v[i + 1]) ++i;
      ++ans;
    }
    if (lens > 1 && v[lens - 1] != v[lens - 2] + 1) ++ans;
    cout << ans << endl;
  }
  return 0;
}
