import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  ps <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve ps

solve :: U.Vector Int -> Int
solve = U.length . U.filter id . (U.zipWith3 monotone <$> id <*> U.tail <*> U.drop 2)
  where
    monotone x y z
      | x < y     = y <= z
      | otherwise = y >= z