import Data.Monoid ((<>))

f :: [Int] -> Ordering -> Int
f [_] _ = 0
f (a:b:as) ord =
    if ord /= EQ && ord' /= EQ && ord /= ord'
        then f (b:as) EQ + 1
        else f (b:as) (ord <> ord')
  where ord' = compare a b
 
main = do
    n <- readLn :: IO Int
    a <- map read . words <$> getLine :: IO [Int]
    print $ 1 + f a EQ