import Data.List
main=do
    [n,x]<-map read.words<$>getLine::IO[Int]
    as<-sort.map read.words<$>getLine::IO[Int]
    print $ s x $ last $ takeWhile (\s->sum s <=x) $ inits as
s x as
    | sum as == x = length as
    | otherwise = max (length as - 1) 0