temp = input().split(" ")
n = int(temp[0])
inp = input().split(" ")
sousa = inp
nsousa = 0
tempn = 0
flag = 0
for a in range(n):
    inp[a] = int(inp[a])
for a in range(n-1):
    # print("a:",a,"flag:",flag)
    if(flag):
        flag = 0
        continue
    if(a+1 != sousa[a] and a+2 != sousa[a+1]):
        pass
    else:
        tempn = sousa[a]
        sousa[a] = sousa[a+1]
        sousa[a+1] = tempn
        nsousa+=1
        if(a!=n-3):
            flag = 1
print(nsousa)
 