#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;
const int inf = 1001001001;
int main(void) {
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  int cnt = 0;
  int cn = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (i + 1 == a[i]) {
      cnt++;
    }
  }
  for (int i = 0; i < (int)(n - 1); i++) {
    if (a[i] == i + 1 && a[i + 1] == i + 2) {
      cnt--;
    }
  }
  cout << cnt << endl;
}
