import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import qualified Data.Set as S

getInts :: IO [Integer]
getInts = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine

inf = 10000000000
solve n as = snd $ foldl f zero as
  where
    dr = snd $ foldl (\(mn,d) x -> (min mn x, max d (x-mn))) (inf,0) as
    zero = (S.empty, 0)
    f (s,a) x = (S.insert x s, a + if (x-dr) `S.member` s then 1 else 0)


main = do
  [n,t] <- getInts
  as <- getInts
  print $ solve n as
