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

for i in range(n-1):
    if i+1 == P[i] and i+2 == P[i+1]:
        ans += 1
    elif i+1 != P[i] and i+2 == P[i+1]:
        ans += 1
    elif i+1 == P[i] and i+2 != P[i+1]:
        continue

if P[0] == 1 and P[1] != 2:
    ans += 1

print(ans)