N = int(eval(input()))

p = list(map(int,input().split()))

l = [0 for k in range(N+2)]



for k in range(N):

    if p[k] == k+1:

        l[k+1] = 1



t = 0

ans = 0

for e in l:

    if e == 1:

        t += 1

    else:

        ans += (t+1)//2

        t = 0

print(ans)

N = int(eval(input()))

p = list(map(int,input().split()))

ans = 0

k = 0

while k < N:

    if p[k] == k+1:

        k += 1

        ans += 1

    k += 1

print(ans)

N = int(eval(input()))
p = list(map(int, input().split()))
l = [0 for k in range(N + 2)]
for k in range(N):
    if p[k] == k + 1:
        l[k + 1] = 1
t = 0
ans = 0
for e in l:
    if e == 1:
        t += 1
    else:
        ans += (t + 1) // 2
        t = 0
print(ans)

N = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
k = 0
while k < N:
    if p[k] == k + 1:
        k += 1
        ans += 1
    k += 1
print(ans)

-l = [0 for k in range(N + 2)] -for k in range(N): +ans = 0 +k = 0 +while k < N: -        l[k + 1] = 1 -t = 0 -ans = 0 -for e in l: -    if e == 1: -        t += 1 -    else: -        ans += (t + 1) // 2 -        t = 0 +        k += 1 +        ans += 1 +    k += 1