<?php

fscanf(STDIN, "%d", $n);
$P = array_map('intval', explode(' ', trim(fgets(STDIN))));

$eq = [];
$tmp = [];
for ($i = 0; $i < $n; ++$i) {
    if ($i + 1 !== $P[$i]) {
        if (empty($tmp)) continue;
        $eq[] = $tmp;
        $tmp = [];
    } else {
        $tmp[] = $P[$i];
    }
}
if (!empty($tmp)) {
    $eq[] = $tmp;
}

$cnt = 0;
foreach ($eq as $arr) {
    if (count($arr) === 1) {
        ++$cnt;
    } else {
        $cnt += count($arr) - 1;
    }
}
echo (int) $cnt;
