#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int n;
  cin >> n;
  long long int a[n];
  long long int s[n];
  memset(s, 0, sizeof(s));
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == i + 1) s[i] = 1;
  }
  long long int ans = 0;
  for (long long int i = 0; i < n;) {
    if (s[i] == 0) {
      i++;
      continue;
    }
    long long int j = i;
    long long int len = 0;
    while (j < n && s[j] == 1) {
      j++;
      len++;
    }
    if (len > 1)
      ans += len - 1;
    else if (len == 1)
      ans += 1;
    i += len;
  }
  cout << ans << endl;
}
