a = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    if a[i] == a[i+1] or a[i+1] == a[i+2] or a[i] == a[i+2]:
        continue
    if a[i] < a[i+1] < a[i+2] or a[i] > a[i+1] > a[i+2]:
        continue
    cnt += 1
print(cnt)