/**
 *      purpose : ABC 72 D
 *      author  : kyomukyomupurin
 *      created : 2018-11-03 02:14:21
**/

#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] = {};
    for (int i = 0; i < N; ++i) cin >> p[i];

    int beg = 0; 
    int sum = 0;
    while (beg < N){
        int end = beg;
        while (end < N && p[end] == end + 1){
            ++end;
        }
        int len = end - beg;
        if (len >= 2) sum += (len - 1);
        else if (len == 1) ++sum;
        
        beg = end + 1;
    }
    print(sum);

    return 0;
}
