import Data.List
main = getLine >> getLine >>= print . solve . fmap read . words

solve :: [Int] -> Int
solve = count (1, mempty)
    where
        count (n, b) (x : y : zs)
            | b /= mempty && c /= mempty && b /= c = count (n + 1, mempty) (y : zs)
            | otherwise = count (n, b `mappend` c) (y : zs)
            where
                c = compare x y
        count (n, _) _ = n
