import Data.List
main = do
    [n, x] <- map read . words <$> getLine
    as <- sort . map read . words <$> getLine
    let ss = scanl (+) 0 as
    let cs = takeWhile (<=x) ss
    print $ if length cs == n + 1 then
                if last cs == x then n else n-1
            else
                length cs - 1