#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long a[n];
  long long count = 0;
  long long left = 0;
  long long right = n - 1;
  long long count_a = 0;
  long long count_b = 0;
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    if (i + 1 == tmp) {
      a[i] = 1;
    } else {
      a[i] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (a[i] == 1) count_a++;
    if (a[i] == 0) count_b++;
  }
  if (count_a == n) {
    cout << n - 1 << endl;
    return 0;
  }
  if (count_b == n) {
    cout << 0 << endl;
    return 0;
  }
  for (long long i = 0; i < n - 1; i++) {
    if (a[i] == 1 && a[i + 1] == 1) {
      count++;
      a[i] = 0;
      a[i + 1] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (a[i] == 1) {
      left = i;
      break;
    }
  }
  for (long long i = n; i >= 0; i--) {
    if (a[i] == 1) {
      right = i;
      break;
    }
  }
  long long add = right - left;
  count += add;
  cout << count << endl;
}
