def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
ans = 0
N = getN()
list = getList()
bind = []
for i,x in enumerate(list):
    if i+1 == x:
        bind.append(x)
for i in range(N//2):
    if list[2*i] == 2*i+1 or list[2*i+1] == 2*i+2:
        ans += 1
if N % 2 == 1:
    if list[-1] == N:
        if list[-3] != N - 2 and list[-2] == N - 1:
            pass
        else:
            ans += 1

print(ans)