#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2147483647;
int main() {
  int N;
  cin >> N;
  int p[N + 1];
  for (int i = 1; i <= N; ++i) cin >> p[i];
  int ans = 0;
  int no = 0;
  for (int i = 1; i <= N; ++i) {
    if (p[i] == i) {
      ++no;
    }
    if (p[i] != i || i == N) {
      if (no == 1) {
        ++ans;
      } else if (no >= 2) {
        ans += no - 1;
      }
      no = 0;
    }
  }
  cout << ans << endl;
  ;
  return 0;
}
