#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  ll N;
  cin >> N;
  vector<ll> p(N);
  for (ll i = 0; i < (N); ++i) cin >> p[i];
  ll ct = 0;
  for (ll i = 0; i < (N); ++i)
    if (p[i] == i + 1) ct++;
  for (ll i = 0; i < (N - 1); ++i)
    if (p[i] == i + 1 && p[i + 1] == i + 2) ct--;
  for (ll i = 0; i < (N - 2); ++i)
    if (p[i] == i + 1 && p[i + 1] == i + 2 && p[i + 2] == i + 3) ct++;
  cout << (ct) << '\n';
  return 0;
}
