n=int(eval(input()))

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

ans=0

i=0

while i<n:

  if i+1==p[i]:

    i+=1

    ans+=1

  i+=1

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

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

i=0

ans=0

while i<n:

  if p[i]==i+1:

    i+=1

    ans+=1

  i+=1

print(ans)
n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
i = 0
while i < n:
    if i + 1 == p[i]:
        i += 1
        ans += 1
    i += 1
print(ans)

n = int(eval(input()))
p = list(map(int, input().split()))
i = 0
ans = 0
while i < n:
    if p[i] == i + 1:
        i += 1
        ans += 1
    i += 1
print(ans)

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