N = int(eval(input()))

p = list(map(int, input().split()))

count = 0

i = 0



while N > i:

    if p[i]-1 == i:

        count += 1

        i += 1

    i+=1

print(count)

import sys

import math

import itertools

import bisect

from copy import copy

from collections import deque,Counter

from decimal import Decimal

def s(): return eval(input())

def i(): return int(eval(input()))

def S(): return input().split()

def I(): return list(map(int,input().split()))

def X(): return list(eval(input()))

def L(): return list(input().split())

def l(): return list(map(int,input().split()))

def lcm(a,b): return a*b//math.gcd(a,b)

sys.setrecursionlimit(10 ** 9)

mod = 10**9+7



N = i()

p = l()

count = 0

i = 0



while i < N:

    if p[i] == i+1:

        count += 1

        i += 1

    i += 1



print(count)

N = int(eval(input()))
p = list(map(int, input().split()))
count = 0
i = 0
while N > i:
    if p[i] - 1 == i:
        count += 1
        i += 1
    i += 1
print(count)

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal


def s():
    return eval(input())


def i():
    return int(eval(input()))


def S():
    return input().split()


def I():
    return list(map(int, input().split()))


def X():
    return list(eval(input()))


def L():
    return list(input().split())


def l():
    return list(map(int, input().split()))


def lcm(a, b):
    return a * b // math.gcd(a, b)


sys.setrecursionlimit(10**9)
mod = 10**9 + 7
N = i()
p = l()
count = 0
i = 0
while i < N:
    if p[i] == i + 1:
        count += 1
        i += 1
    i += 1
print(count)

-N = int(eval(input())) -p = list(map(int, input().split())) +import sys +import math +import itertools +import bisect +from copy import copy +from collections import deque, Counter +from decimal import Decimal + + +def s(): +    return eval(input()) + + +def i(): +    return int(eval(input())) + + +def S(): +    return input().split() + + +def I(): +    return list(map(int, input().split())) + + +def X(): +    return list(eval(input())) + + +def L(): +    return list(input().split()) + + +def l(): +    return list(map(int, input().split())) + + +def lcm(a, b): +    return a * b // math.gcd(a, b) + + +sys.setrecursionlimit(10**9) +mod = 10**9 + 7 +N = i() +p = l() -while N > i: -    if p[i] - 1 == i: +while i < N: +    if p[i] == i + 1: