import copy



n=int(eval(input()))

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

f2=copy.deepcopy(f1)

c=0

for i in range(n-1):

    if f1[i]==i+1:

        c+=1

        f1[i],f1[i+1]=f1[i+1],f1[i]



for i in range(n-1,0,-1):

    #print(d)

    if f1[i]==i+1:

        c+=1

        f1[i],f1[i-1]=f1[i-1],f1[i]



print(c)

n=int(eval(input()))

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

c=0

for i in range(n-1):

    if f[i]==i+1:

        c+=1

        f[i],f[i+1]=f[i+1],f[i]

if f[n-1]==n:

  	f[n-2],f[n-1]=f[n-1],f[n-2]

  	c+=1  

print(c)
import copy

n = int(eval(input()))
f1 = list(map(int, input().split()))
f2 = copy.deepcopy(f1)
c = 0
for i in range(n - 1):
    if f1[i] == i + 1:
        c += 1
        f1[i], f1[i + 1] = f1[i + 1], f1[i]
for i in range(n - 1, 0, -1):
    # print(d)
    if f1[i] == i + 1:
        c += 1
        f1[i], f1[i - 1] = f1[i - 1], f1[i]
print(c)

n = int(eval(input()))
f = list(map(int, input().split()))
c = 0
for i in range(n - 1):
    if f[i] == i + 1:
        c += 1
        f[i], f[i + 1] = f[i + 1], f[i]
if f[n - 1] == n:
    f[n - 2], f[n - 1] = f[n - 1], f[n - 2]
    c += 1
print(c)

-import copy - -f1 = list(map(int, input().split())) -f2 = copy.deepcopy(f1) +f = list(map(int, input().split())) -    if f1[i] == i + 1: +    if f[i] == i + 1: -        f1[i], f1[i + 1] = f1[i + 1], f1[i] -for i in range(n - 1, 0, -1): -    # print(d) -    if f1[i] == i + 1: -        c += 1 -        f1[i], f1[i - 1] = f1[i - 1], f1[i] +        f[i], f[i + 1] = f[i + 1], f[i] +if f[n - 1] == n: +    f[n - 2], f[n - 1] = f[n - 1], f[n - 2] +    c += 1