from itertools import groupby



n = eval(input())

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

lii = [val == (itr + 1) for itr, val in enumerate(li)]

gbli = [[key, len(list(group))] for key, group in groupby(lii)]

 

ans = 0

for key, val in gbli:

  if key:

    ans += (val - 1) // 2 + 1

    

print(ans)

from itertools import groupby

n = int(eval(input()))

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

T = [val == (itr + 1) for itr, val in enumerate(P)]



ans = 0

for k, v in groupby(T):

  if k == True:

    ans += (sum(v) - 1) // 2 + 1

    

print(ans)
from itertools import groupby

n = eval(input())
li = list(map(int, input().split()))
lii = [val == (itr + 1) for itr, val in enumerate(li)]
gbli = [[key, len(list(group))] for key, group in groupby(lii)]
ans = 0
for key, val in gbli:
    if key:
        ans += (val - 1) // 2 + 1
print(ans)

from itertools import groupby

n = int(eval(input()))
P = list(map(int, input().split()))
T = [val == (itr + 1) for itr, val in enumerate(P)]
ans = 0
for k, v in groupby(T):
    if k == True:
        ans += (sum(v) - 1) // 2 + 1
print(ans)

-n = eval(input()) -li = list(map(int, input().split())) -lii = [val == (itr + 1) for itr, val in enumerate(li)] -gbli = [[key, len(list(group))] for key, group in groupby(lii)] +n = int(eval(input())) +P = list(map(int, input().split())) +T = [val == (itr + 1) for itr, val in enumerate(P)] -for key, val in gbli: -    if key: -        ans += (val - 1) // 2 + 1 +for k, v in groupby(T): +    if k == True: +        ans += (sum(v) - 1) // 2 + 1