#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++;
        if (i + 1 == n - 1) {
          break;
        }
      } else {
        if (a[i] - 1 != a[i - 1] || i == 0) {
          ans++;
        }
      }
    }
  }
  if (cnt == 0) {
    cout << (ans) << endl;
    return 0;
  }
  if ((cnt + 1) % 2 == 0) {
    cout << (ans + (cnt + 1) / 2) << endl;
  } else {
    cout << (ans + (cnt + 1) / 2 + 1) << endl;
  }
  return 0;
}
