n = int(eval(input()))

p = [int(i) for i in input().split()]

i = 0

ans = 0

while i < n:

    if i < n - 1:

        if p[i] == i + 1:

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

            ans += 1

    elif p[i] == i + 1:

        ans += 1

    i += 1

print(ans)

n = int(eval(input()))

p = [int(i) for i in input().split()]

ans = 0

for i in range(n):

    if i < n - 1:

        if p[i] == i + 1:

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

            ans += 1

    elif p[i] == i + 1:

        ans += 1

print(ans)

n = int(eval(input()))
p = [int(i) for i in input().split()]
i = 0
ans = 0
while i < n:
    if i < n - 1:
        if p[i] == i + 1:
            p[i], p[i + 1] = p[i + 1], p[i]
            ans += 1
    elif p[i] == i + 1:
        ans += 1
    i += 1
print(ans)

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

-i = 0 -while i < n: +for i in range(n): -    i += 1