solve :: [Int] -> Int
solve [] = 0
solve as | length as < 3 = 0
         | (x > y && y > z) = 1 + (solve (tail as))
         | (x < y && y < z) = 1 + (solve (tail as))
         | otherwise = solve (tail as)
            where
                x = as!!0
                y = as!!1
                z = as!!2

main = do
    n <- readLn :: IO Int
    pn <- map read . words <$> getLine :: IO [Int]
    print $ solve pn
