n = int(input())
a = list(map(int,input().split()))

t = 0
cnt = 0
for i in range(n):
    if a[i] == i+1:
        t += 1

if n % 2 == 1:
    n -= 1
    
for i in range(0,n,2):
    if (a[i] == i+1) and (a[i+1] == i+2):
        cnt += 1

print(t-cnt)