import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [n, x] <- fmap read . words <$> getLine :: IO [Int]
    as <- fmap read . words <$> getLine :: IO [Int]
    case x `compare` sum as of
        LT -> do
            let bs = takeWhile (<= x) $ scanl1 (+) (sort as)
            print $ length bs
        EQ -> print n
        GT -> print (n - 1)
