solve :: [Int] -> Int
solve (a:b:as)
  | a == b = solve (b:as)
  | a <= b = f (<=) (b:as)
  | otherwise = f (>=) (b:as)
  where
    f r (a:b:as)
      | r a b = f r (b:as)
      | otherwise = 1 + solve (b:as)
    f _ [_] = 1
solve [_] = 1

main = getLine >> getLine >>= print.solve.map read.words