void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    int cnt, tmp;
    foreach (i; 0 .. n) {
        if (i == n - 1 && a[i] == n) {
            tmp = a[i];
            a[i] = a[i-1];
            a[i-1] = tmp;
            ++cnt;
        } else if (a[i] == i + 1) {
            tmp = a[i];
            a[i] = a[i+1];
            a[i+1] = tmp;
            ++cnt;
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;