n = int(input())
p = list(map(int, input().split()))
out = [0]*n
for i in range(n):
    if p[i] == i+1:
        out[i] = 1
#print(out)

ans1 = 0
for i in range(n-1)[::2]:
    if out[i] == 0 and out[i+1] == 0:
        continue
    elif out[i] == 0 and out[i+1] == 1:
        ans1 += 1
    elif out[i] == 1 and out[i+1] == 0:
        ans1 += 1
    elif out[i] == 1 and out[i+1] == 1:
        ans1 += 1
if n % 2 == 1 and out[-1] == 1:
    ans1 += 1

ans2 = 0
for i in range(1, n)[::2]:
    if out[-i-1] == 0 and out[-i] == 0:
        continue
    elif out[-i-1] == 0 and out[-i] == 1:
        ans2 += 1
    elif out[-i-1] == 1 and out[-i] == 0:
        ans2 += 1
    elif out[-i-1] == 1 and out[-i] == 1:
        ans2 += 1
if n % 2 == 1 and out[0] == 1:
    ans2 += 1
    
print(min(ans1, ans2))




