import Data.List (group)

solve [_] cnt upper = cnt
solve [x0,x1] cnt upper
  | x0 < x1 && upper = cnt
  | x0 > x1 && not upper = cnt
  | otherwise = cnt+1
solve (x0:x1:x2:xs) cnt upper
  | x0 < x1 && upper = solve (x1:x2:xs) cnt upper
  | x0 > x1 && not upper = solve (x1:x2:xs) cnt upper
  | otherwise = solve (x2:xs) (cnt+1) (x1<x2)

main = do
  n <- read <$> getLine :: IO Int
  as <- map head.group.map read.words <$> getLine :: IO [Int]
  print $  solve as 1 (head as<(head.tail) as)
