#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n;
  int a[n], b[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != i) a[i] = 0;
    b[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0)
      s = s++;
    else
      b[i - 1] = s;
    s = 0;
  }
  s = 0;
  for (int i = 1; i <= n; i++) {
    if (b[i] / 2 == 0) {
      b[i] = b[i] / 2;
    } else {
      b[i] = (b[i] + 1) / 2;
    }
    s = s + b[i];
  }
  cout << s;
  return 0;
}
