import Data.List
main = do
  n <- readLn :: IO Int
  p <- map (read::String->Int) . words <$> getLine
  print $ f p 0

f (_:_:[]) counter = counter
f (x:y:z:xs) counter
  |x<y && y<z = f (y:z:xs) (counter+1)
  |x>y && y>z = f (y:z:xs) (counter+1)
  |otherwise  = f (y:z:xs)  counter