#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define int long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;
const double P = 3.141592653589793238462643;

int a[N], c[N], cnt, mx = -inf, cnt2, u[N];

main()
{
    int n;
    cin >> n;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
    }
    for( int i = 1; i <= n; i++ )
    {
        if( a[i] == i )
        {
            if( a[i + 1] == i + 1 )
            {
                cnt++;
                u[i + 1] = 1;
                continue;
            }
            if( u[i] == 0 )
                cnt2 ++;
//            cout << a[i + 1] << "  "<< i + 1 << endl;
        }
    }
    cout << cnt + cnt2;
}
