from itertools import groupby

def ceil(x, y):

  return (x -1) // y + 1



eval(input())

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

lii = []

for itr, val in enumerate(li):

  if itr + 1 == val:

    lii.append(True)

  else:

    lii.append(False)

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



ans = 0

for i,j in gbli:

  if i == True:

    ans += ceil(j, 2)

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


def ceil(x, y):
    return (x - 1) // y + 1


eval(input())
li = list(map(int, input().split()))
lii = []
for itr, val in enumerate(li):
    if itr + 1 == val:
        lii.append(True)
    else:
        lii.append(False)
gbli = [[key, len(list(group))] for key, group in groupby(lii)]
ans = 0
for i, j in gbli:
    if i == True:
        ans += ceil(j, 2)
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)

- -def ceil(x, y): -    return (x - 1) // y + 1 - - -eval(input()) +n = eval(input()) -lii = [] -for itr, val in enumerate(li): -    if itr + 1 == val: -        lii.append(True) -    else: -        lii.append(False) +lii = [val == (itr + 1) for itr, val in enumerate(li)] -for i, j in gbli: -    if i == True: -        ans += ceil(j, 2) +for key, val in gbli: +    if key: +        ans += (val - 1) // 2 + 1