n=int(eval(input()))

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

cnt=0

p2=[]

for i,x in enumerate(p):

    if (i+1)==p[i]:

        p2.append(False)

    else:

        p2.append(True)



for i in range(n-1):

    if p2[i]==False and p2[i+1]==True:

        p2[i]=True

        cnt+=1

    if p2[i]==False and p2[i+1]==False:

        p2[i]=True

        p2[i+1]=True

        cnt+=1

if p2[-1]==False:

    cnt+=1

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

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

cnt=0

for i in range(n-1):

        if p[i]==(i+1):

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

            cnt+=1

if p[-1]==n:

    cnt+=1

 

print(cnt)

n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
p2 = []
for i, x in enumerate(p):
    if (i + 1) == p[i]:
        p2.append(False)
    else:
        p2.append(True)
for i in range(n - 1):
    if p2[i] == False and p2[i + 1] == True:
        p2[i] = True
        cnt += 1
    if p2[i] == False and p2[i + 1] == False:
        p2[i] = True
        p2[i + 1] = True
        cnt += 1
if p2[-1] == False:
    cnt += 1
print(cnt)

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

-p2 = [] -for i, x in enumerate(p): -    if (i + 1) == p[i]: -        p2.append(False) -    else: -        p2.append(True) -    if p2[i] == False and p2[i + 1] == True: -        p2[i] = True +    if p[i] == (i + 1): +        p[i], p[i + 1] = p[i + 1], p[i] -    if p2[i] == False and p2[i + 1] == False: -        p2[i] = True -        p2[i + 1] = True -        cnt += 1 -if p2[-1] == False: +if p[-1] == n: