#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  int count = 0;
  int rinsetsu = 0;
  for (int i = 1; i <= n; i++) {
    if (i == p[i]) count++;
    if (i < n && i == p[i] && i + 1 == p[i + 1]) rinsetsu++;
  }
  int temp = count - 2 * rinsetsu;
  int ans = (rinsetsu + 1) / 2 + temp;
  cout << ans << endl;
  return 0;
}
