#include <bits/stdc++.h>
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:367077216")
using namespace std;
const long double EPS = 1e-5;
const long double EPS2 = 1e-6;
const long double PI = acos(-1);
const long long MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const long long inf = 1e9;
const long long INF = 1000 * 1000 * 1000ll * 1000 * 1000 * 1000;
const long long kekmod = 1791791791;
const long long bestmod = 1148822869;
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long i = 0; i < a.size(); ++i) cin >> a[i];
  ;
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] - 1 == i) {
      cnt++;
    } else {
      ans += (cnt + 1) / 2;
      cnt = 0;
    }
  }
  cout << ans;
  system("pause");
}
