/**
 *      purpose : ABC 72 D
 *      author  : kyomukyomupurin
 *      created : 2018-10-26 00:03:51
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int p[N + 1] = {};
    for (int i = 0; i < N; ++i) cin >> p[i];
    p[N] = N + 100;

    int cnt = 0;

    for (int i = 0; i < N; ++i) {
        if (p[i] == i + 1) ++ cnt;
    }

    int len = 0;

    for (int i = 0; i < N - 1; ++i) {
        if (p[i] == i + 1 && p[i + 1] == i + 2 && p[i + 2] != i + 3) ++len;
    }

    print(cnt - len);

    return 0;
}