#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
ll ans;
string S;
ll N;
ll T[101];
ll p[100001];

int main() {
	cin >> N;
	rep(i, 1, N + 1) {
		cin >> p[i];
	}
	ans = 0;
	ll count = 0;
	rep(i, 1, N + 1) {
		if (p[i] == i) {
			count++;
			if (count == 2) {
				count = 0;
				ans++;
			}
		}
		else {
			if (count == 1) {
				count = 0;
				ans++;
			}
		}
	}
	if (count == 1) {
		count = 0;
		ans++;
	cout << ans << endl;
	cin >> ans;
	return 0;
}
