import           Data.List (sort)
  
main :: IO ()
main = do
    [n, x] <- map read . words <$> getLine
    as <- map read . words <$> getLine
    print $ solve n x as

solve :: Int -> Int -> [Int] -> Int
solve n x as
    | sum as == x = n
    | sum as < x = n - 1
    | otherwise = length $ takeWhile (<= x) $ scanl1 (+) $ sort as