
import Data.List
import Data.Char

foo :: [Int] -> Int
foo ints
  | length ints <= 2 = 0
  | otherwise = bar ints
    where
      bar (a:b:c:cs) =
        if (a < b && b < c) || (a > b  && b > c) then 1 + foo (b:c:cs)
        else foo (b:c:cs)

main = do
  _ <- getLine
  ints <- map read . words <$> getLine :: IO [Int]
  print $ foo ints

