#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(a,b,n) for(ll a = (ll)(b); a < (ll)(n); a++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	vint p(n);
	rep(i,n) cin >> p[i];
	int ans = 0;
	rep(i,n) {
		if(a[i]==i+1) {
			if(i!=n-1) swap(p[i],p[i+1]);
			else swap(p[i],p[i-1]);
			ans++;
		}
	}
	rep(i,n) {
		if(p[i]==i+1) {
			if(i!=n-1) swap(p[i],p[i+1]);
			else swap(p[i],p[i-1]);
			ans++;
		}
	}
	cout << ans << endl;
}