N = int(eval(input()))

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

 

cont = 0

ans = 0

for idx, pi in enumerate(p):

    i = idx + 1

 

    if i == pi:

        cont += 1

    else:

        ans += (cont + 1) // 2

        cont = 0

 

ans += (cont + 1) // 2

print(ans)
N = int(eval(input()))



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



ans = 0



for i in range(N):

    if P[i] == i+1:

        if i < N-1:

            now = P[i]

            P[i] = P[i+1]

            P[i+1] = now

        ans += 1

print(ans)
N = int(eval(input()))
p = tuple(map(int, input().split()))
cont = 0
ans = 0
for idx, pi in enumerate(p):
    i = idx + 1
    if i == pi:
        cont += 1
    else:
        ans += (cont + 1) // 2
        cont = 0
ans += (cont + 1) // 2
print(ans)

N = int(eval(input()))
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if P[i] == i + 1:
        if i < N - 1:
            now = P[i]
            P[i] = P[i + 1]
            P[i + 1] = now
        ans += 1
print(ans)

-p = tuple(map(int, input().split())) -cont = 0 +P = list(map(int, input().split())) -for idx, pi in enumerate(p): -    i = idx + 1 -    if i == pi: -        cont += 1 -    else: -        ans += (cont + 1) // 2 -        cont = 0 -ans += (cont + 1) // 2 +for i in range(N): +    if P[i] == i + 1: +        if i < N - 1: +            now = P[i] +            P[i] = P[i + 1] +            P[i + 1] = now +        ans += 1