import Data.List

main :: IO ()
main = do
  (n:x:_) <- map read . words <$> getLine :: IO [Int]
  as <- sort . map read . words <$> getLine
  let (left, right) = span (<= x) $ scanl1 (+) as 
      sm = sum as
      len = length left
      ans = if null right && sm < x then len-1 else len 
  putStrLn $ show $ ans
