import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
P = inintl()

ans = 0

if n == 2:
    if P[0] == 1:
        print(1)
        exit()
    else:
        print(0)
        exit()

for i in range(n):
    if i+1 == P[i]:
        if i+2 == P[i+1]:
            continue
        else:
            ans += 1

print(ans)