#34957: Python解


popo0816@apps.ntpc.edu.tw (壽溥謙)


hl = input()
hlList = hl.split()
total = 0
i = 2
while i < len(hlList)-1:
    if int(hlList[i]) == int(hlList[i+1]):
        hlList.pop(i+1)
    if int(hlList[i]) == int(hlList[i-1]):
        hlList.pop(i-1)
    i += 1
for j in range(2,len(hlList)-1):
    if int(hlList[j]) > int(hlList[j+1]) and int(hlList[j]) > int(hlList[j-1]):
        total += 1
print(total)