N = int(eval(input()))

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

import queue

from math import ceil

que = queue.Queue()

ans = 0

for i in range(N):

    if p[i]==i+1:

        que.put(i)

    else:

        ans+=ceil(que.qsize()/2)

        que = queue.Queue()

ans+=ceil(que.qsize()/2)

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

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



ans = 0

i = 0

while i < N:

    if p[i] == i+1:

        ans += 1

        if i+1 < N and p[i+1]==i+2:

            i += 1

    i += 1

print(ans)
N = int(eval(input()))
p = list(map(int, input().split()))
import queue
from math import ceil

que = queue.Queue()
ans = 0
for i in range(N):
    if p[i] == i + 1:
        que.put(i)
    else:
        ans += ceil(que.qsize() / 2)
        que = queue.Queue()
ans += ceil(que.qsize() / 2)
print(ans)

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

-import queue -from math import ceil - -que = queue.Queue() -for i in range(N): +i = 0 +while i < N: -        que.put(i) -    else: -        ans += ceil(que.qsize() / 2) -        que = queue.Queue() -ans += ceil(que.qsize() / 2) +        ans += 1 +        if i + 1 < N and p[i + 1] == i + 2: +            i += 1 +    i += 1