import Control.Monad (replicateM )
import Data.List (minimum, scanl', sort, sortBy)
import qualified Data.Vector.Unboxed as U

import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

getParm :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,x] <- getParm
  as    <- getParm
  print $ f n x as

f :: Int -> Int -> [Int] -> Int
f n x as
  | k < n  = k   
  | x < 2*sas = lengthUpto (2*sas-x) sa
  | otherwise = 0
  where
    lengthUpto x = U.length . U.takeWhile (<= x) 
    k = lengthUpto x sums
    sums = U.scanl1 (+) as'
    as' = U.fromList $ sort as

    sas = sum as
    sa  = U.reverse as' 