#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int main(void) {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  for (int i = 0; i < (int)(n); i++) cin >> p[i + 1];
  vector<int> ans;
  for (int i = 1; i <= n; ++i) {
    if (i == p[i]) {
      ans.push_back(i);
    }
  }
  ll rep = ans.size();
  for (int i = 0; i < (int)(ans.size() - 1); i++) {
    if (ans[i] + 1 == ans[i + 1]) {
      rep--;
    }
  }
  cout << rep << endl;
  return 0;
}
