#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
long long int n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
int main() {
  cin >> n;
  vector<long long int> v(n), a(n);
  for (long long int i = (long long int)(0); i < (long long int)(n); i++)
    cin >> v[i];
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    if (v[i] == i + 1) {
      a[i] = 1;
    } else {
      a[i] = 0;
    }
  }
  if (a[0] == 1) {
    swap(v[0], v[1]);
    a[0] = 0;
    if (v[1] == 2) {
      a[1] = 1;
    } else {
      a[1] = 0;
    }
    cnt++;
  }
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    if (a[i] == 1) {
      a[i] = 0;
      if (a[i + 1] == 1) {
        swap(v[i], v[i + 1]);
        a[i] = a[i + 1] = 0;
      } else if (v[i + 1] > i) {
        swap(v[i], v[i + 1]);
        if (v[i + 1] == i + 2) {
          a[i + 1] = 1;
        } else {
          a[i + 1] = 0;
        }
      } else {
        swap(v[i], v[i - 1]);
        if (v[i - 1] == i) {
          a[i - 1] = 1;
        } else {
          a[i - 1] = 0;
        }
      }
      cnt++;
    }
  }
  if (a[n - 1] == 1) {
    swap(v[n - 1], v[n - 2]);
    a[n - 1] = 0;
    if (v[n - 1] == n) {
      a[n - 2] = 1;
    } else {
      a[n - 2] = 0;
    }
    cnt++;
  }
  cout << cnt << endl;
}
