N=int(input())
p=list(map(int, input().split()))
p = [0] + p
ans = 0
if N%2==0:
    for i in range(1, N+1, 2):
        if p[i]==i or p[i+1]==i+1:
            ans += 1
    print(ans)
else:
    for i in range(1, N-1, 2):
        if i == N-2:
            if p[i]==i and p[i+1]==i+1 and p[i+2]==i+2:
                ans += 2
            if p[i]==i and p[i+1]==i+1 and p[i+2]!=i+2:
                ans += 1
            if p[i]==i and p[i+1]!=i+1 and p[i+2]==i+2:
                ans += 2
            if p[i]==i and p[i+1]!=i+1 and p[i+2]!=i+2:
                ans += 1
            if p[i]!=i and p[i+1]==i+1 and p[i+2]==i+2:
                ans += 1
            if p[i]!=i and p[i+1]==i+1 and p[i+2]!=i+2:
                ans += 1
            if p[i]!=i and p[i+1]!=i+1 and p[i+2]==i+2:
                ans += 1
            else:
                pass
            break
        if p[i]==i or p[i+1]==i+1:
            ans += 1
    print(ans)
