
import System.IO
import Control.Applicative ((<$>))

data T a = Above a | Below a
isAbove (Above _) = True
isAbove (Below _) = False
isBelow = not . isAbove
unpack (Above a) = a
unpack (Below b) = b


begin :: [Int] -> T Int
begin [a] = Above a
begin (a:b:xs) | a > b = Above a | a < b = Below a

tourist :: [Int] -> [T Int]
tourist [a] = []
tourist [a,b] | a < b = [Above b]
              | a > b = [Below b]
tourist (a:b:c:xs) | a < b && b > c = (Above b):(tourist (b:c:xs))
                   | a > b && b < c = (Below b):(tourist (b:c:xs))
                   | otherwise      = tourist (b:c:xs)

marchant :: [T Int] -> [(Int, Int, Int)]
marchant [] = []
marchant ((Below b):xs) = (b,m,m-b):(marchant xs)
  where
    aboves = unpack <$> filter isAbove xs
    m = maximum aboves
marchant (x:xs) = marchant xs

maxof :: [(Int,Int,Int)] -> [(Int,Int,Int)]
maxof ls = filter (topof m) ls
  where
    topof x (_,_,a) = x == a
    m = foldl f 0 ls
    f x (_,_,a) = max x a

main = do
  s1 <- getLine
  let (num:lim:_) = (\x -> read x :: Int) <$> words s1
  s2 <- getLine
  let towns = read <$> words s2
  let b = begin towns
  (putStrLn . show . length . maxof . marchant) $ (b:tourist towns)