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)
ans = 0
flag = False
for i in range(n-1)[::2]:
    if out[i] == 0 and out[i+1] == 0:
        flag = False
    elif out[i] == 0 and out[i+1] == 1:
        ans += 1
        flag = True
    elif out[i] == 1 and out[i+1] == 0 and not flag:
        ans += 1
    elif out[i] == 1 and out[i+1] == 0 and flag:
        Flag = False
    elif out[i] == 1 and out[i+1] == 1:
        ans += 1
        flag = True


if n % 2 == 1 and out[-1] == 1 and not flag:
    ans += 1

print(ans)



