n = int(eval(input()))

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

l = [0]*n

ans = 0

for i in range(n):

  if temp[i] == i+1:

    l[i] = 0

  else:

    l[i] = 1



for i in range(n):

  if l[i] == 0 and i == n-1:

    ans += 1

  if l[i] == 0 and not i == n-1:

    l[i] = 1

    l[i+1] = 1

    ans += 1



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

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

ans = 0

for i in range(n):

  if l[i] == i + 1 and i == n-1:

    ans += 1

  if l[i] == i + 1 and not i == n-1:

    l[i], l[i+1] = l[i+1], l[i]

    ans += 1

print(ans)
n = int(eval(input()))
temp = list(map(int, input().split()))
l = [0] * n
ans = 0
for i in range(n):
    if temp[i] == i + 1:
        l[i] = 0
    else:
        l[i] = 1
for i in range(n):
    if l[i] == 0 and i == n - 1:
        ans += 1
    if l[i] == 0 and not i == n - 1:
        l[i] = 1
        l[i + 1] = 1
        ans += 1
print(ans)

n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    if l[i] == i + 1 and i == n - 1:
        ans += 1
    if l[i] == i + 1 and not i == n - 1:
        l[i], l[i + 1] = l[i + 1], l[i]
        ans += 1
print(ans)

-temp = list(map(int, input().split())) -l = [0] * n +l = list(map(int, input().split())) -    if temp[i] == i + 1: -        l[i] = 0 -    else: -        l[i] = 1 -for i in range(n): -    if l[i] == 0 and i == n - 1: +    if l[i] == i + 1 and i == n - 1: -    if l[i] == 0 and not i == n - 1: -        l[i] = 1 -        l[i + 1] = 1 +    if l[i] == i + 1 and not i == n - 1: +        l[i], l[i + 1] = l[i + 1], l[i]