#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MAX = 1000000;
const int MOD = 1000000007;
int main() {
  int n;
  vector<int> v(n);
  int p;
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    cin >> p;
    if (i == p - 1)
      v[i] = 0;
    else
      v[i] = 1;
  }
  int ans = 0;
  int count = 0;
  for (i = 0; i < n; i++) {
    if (v[i] == 0) {
      count++;
    } else {
      if (count == 0) {
        continue;
      } else if (count == 1) {
        ans += count;
        count = 0;
      } else {
        ans += (count - 1);
        count = 0;
      }
    }
  }
  if (count == 1) {
    ans += count;
  } else if (count > 1) {
    ans += (count - 1);
  }
  cout << ans << endl;
}
