n = int(eval(input()))

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



cnt = 0

for i in range(n):

    if p[i] == i + 1:

        if i == 0:

            p[i], p[i + 1] = p[i + 1], p[i]

        elif i == n-1:

            p[i], p[i - 1] = p[i - 1], p[i]

        else:

            if p[i - 1] == i + 1:

                p[i], p[i - 1] = p[i - 1], p[i]

            else:

                p[i], p[i + 1] = p[i + 1], p[i]

        cnt += 1



print(cnt)
n = int(eval(input()))

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



cnt = 0

for i in range(n):

    if p[i] == i + 1:

        if i == 0:

            p[i], p[i + 1] = p[i + 1], p[i]

        elif i == n-1:

            p[i], p[i - 1] = p[i - 1], p[i]

        else:

            

             p[i], p[i + 1] = p[i + 1], p[i]

        cnt += 1



print(cnt)
n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] == i + 1:
        if i == 0:
            p[i], p[i + 1] = p[i + 1], p[i]
        elif i == n - 1:
            p[i], p[i - 1] = p[i - 1], p[i]
        else:
            if p[i - 1] == i + 1:
                p[i], p[i - 1] = p[i - 1], p[i]
            else:
                p[i], p[i + 1] = p[i + 1], p[i]
        cnt += 1
print(cnt)

n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] == i + 1:
        if i == 0:
            p[i], p[i + 1] = p[i + 1], p[i]
        elif i == n - 1:
            p[i], p[i - 1] = p[i - 1], p[i]
        else:
            p[i], p[i + 1] = p[i + 1], p[i]
        cnt += 1
print(cnt)

-            if p[i - 1] == i + 1: -                p[i], p[i - 1] = p[i - 1], p[i] -            else: -                p[i], p[i + 1] = p[i + 1], p[i] +            p[i], p[i + 1] = p[i + 1], p[i]