{-# OPTIONS_GHC -O2 -optc-O2 #-}
module Main where

import Control.Monad
import Control.Monad.State
import Data.List
import qualified Data.ByteString.Lazy.Char8 as L

data Type = Increasing | Decreasing | Unknown
            deriving (Show, Eq)

unique :: (Eq a) => [a] -> [a]
unique = map head . group

getType :: Int -> Int -> Type
getType x y | x < y = Increasing
            | otherwise = Decreasing

solve :: [Int] -> Int
solve xs = groups + 1
    where (h:ts) = unique xs
          (groups, _, _) = foldl' update (0, Unknown, h) ts
          update (ng, t, x) y = case t of
                                  Unknown -> (ng, getType x y, y)
                                  Increasing -> if x < y
                                                then (ng, t, y)
                                                else (ng + 1, Unknown, y)
                                  Decreasing -> if x > y
                                                then (ng, t, y)
                                                else (ng + 1, Unknown, y)

test0 = [1, 2, 3, 2, 2, 1] :: [Int]
test1 = [1, 2, 1, 2, 1, 2, 1, 2, 1] :: [Int]
test2 = [1, 2, 3, 2, 1, 999999999, 1000000000] :: [Int]

type Tokenizer = State [L.ByteString]

nextInt :: Tokenizer Int
nextInt = state $ \(s:ss) -> case L.readInt s of
                               Just (x, _) -> (x, ss)
                               Nothing -> error $ "Can't parse Int from: " ++ (L.unpack s)

go :: Tokenizer Int
go = do
  n <- nextInt
  xs <- replicateM n nextInt
  return $ solve xs

main :: IO ()
main = do
  contents <- L.getContents
  let result = evalState go (L.words contents)
  print result
