#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<ll> ps(N, 0);
    for (auto &&i: boost::irange(0LL, N)) {
        ll p;
        cin >> p;
        p--;
        ps.at(i) = p;
    }
    vector<bool> bs(N, false);
    for (auto &&i: boost::irange(0LL, N)) {
        bs.at(i) = ps.at(i) == i ? true : false;
    }
    ll count{0};
    for (auto &&i: boost::irange(0LL, N - 1)) {
        if (bs.at(i) == true && bs.at(i + 1) == true) {
            bs.at(i) = false;
            bs.at(i+1) = false;
            count++;
        } else if (bs.at(i) == true){
            bs.at(i) = false;
            count++;
        }
    }
    if (bs.at(N) == true)count++;
    cout << count;
    return 0;
}