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

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

f :: Int -> [Int] -> Int
f x as
  | x < head as' = 0
  | x <= sum as  = length $ takeWhile (< x) $ scanl' (+) 0 as'
  | x <= 2 * sas = length $ takeWhile (< (2*sas - x)) $ scanl' (+) 0 sa
  | otherwise    = 0
  where
    sas = sum as
    as' = sort as
    sa  = sortBy (flip compare) as