import Control.Monad (replicateM)
import Data.List (minimum, scanl', sort, sortBy)

main :: IO ()
main = do
  [n,x] <- map read . words <$> getLine 
  as    <- map read . words <$> getLine
  print $ f n x as

f :: Int -> Int -> [Int] -> Int
f n x as
  | x < minas = 0
  | x <= sas  = length $ takeWhile (<= x) $ scanl' (+) b bs
  | x <  2 * sas = length $ takeWhile (<= (2*sas - x)) $ scanl' (+) c cs
  | otherwise    = 0
  where
    minas = minimum as
    sas = sum as
    as'@(b:bs) = sort as
    sa@(c:cs)  = sortBy (flip compare) as