n=int(eval(input()))

a=list([int(x)-1 for x in input().split()])



cnt=0

lis=set()

for i in range(n-1):

    if i in lis:

        continue

    if a[i]==i and a[i+1]==i+1:

        cnt+=1

        lis.add(i+1)

    elif a[i]==i:

        cnt+=1

if n-1 not in lis and a[n-1]==n-1:

    cnt+=1

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

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

ans=0

for i in range(n):

    if i+1==a[i]:

        ans+=1

        if i!=n-1:

            a[i+1]=a[i]

print(ans)
n = int(eval(input()))
a = list([int(x) - 1 for x in input().split()])
cnt = 0
lis = set()
for i in range(n - 1):
    if i in lis:
        continue
    if a[i] == i and a[i + 1] == i + 1:
        cnt += 1
        lis.add(i + 1)
    elif a[i] == i:
        cnt += 1
if n - 1 not in lis and a[n - 1] == n - 1:
    cnt += 1
print(cnt)

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

-a = list([int(x) - 1 for x in input().split()]) -cnt = 0 -lis = set() -for i in range(n - 1): -    if i in lis: -        continue -    if a[i] == i and a[i + 1] == i + 1: -        cnt += 1 -        lis.add(i + 1) -    elif a[i] == i: -        cnt += 1 -if n - 1 not in lis and a[n - 1] == n - 1: -    cnt += 1 -print(cnt) +a = list(map(int, input().split())) +ans = 0 +for i in range(n): +    if i + 1 == a[i]: +        ans += 1 +        if i != n - 1: +            a[i + 1] = a[i] +print(ans)