import Data.List
import Data.Ord
type City = (Int,Int)
main = do
    [n,t] <- input <$> getLine
    a <- input <$> getContents 
    let city = zip [1..] a
    putStrLn $ show $ answer city

input :: String -> [Int]
input = map read . words
answer :: [City] -> Int
answer a =  let mb = maxBenefitsOfSubList a []
            in length $ filter (== maximum mb) mb
maxBenefitsOfSubList :: [City] -> [Int] -> [Int]
maxBenefitsOfSubList [] maxbene = maxbene
maxBenefitsOfSubList [x] maxbene = maxbene
maxBenefitsOfSubList cities maxbene = 
    let maxcity = maximumA cities
        mincity = minimumA cities
    in  if maxcity > mincity
        then (snd maxcity - snd mincity):maxbene
        else let (first,last) = span (<=maxcity) cities
             in    maxBenefitsOfSubList first maxbene
                ++ maxBenefitsOfSubList last maxbene

maximumA :: [City] -> City
maximumA = maximumBy $ comparing snd 
minimumA :: [City] -> City
minimumA = minimumBy $ comparing snd
