#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const long long LINF = 1e18;
long long int n, cnt = 0, ans = 0, a[10000000], b, c, cmp, cmpp, m, h, w, x, y,
                 sum = 0, pos;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl = true;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long int(i) = 0; (i) < (int)(n); (i)++) cin >> a[i];
  for (long long int(i) = 0; (i) < (int)(n); (i)++) {
    pos = i + 1;
    if (a[i] == pos) {
      if (a[i] + 1 == a[i + 1]) {
        cnt++;
      } else {
        ans++;
      }
    }
  }
  cout << (ans + cnt / 2) << endl;
  return 0;
}
