import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve n x as = if k < n then k
               else if sum as == x then n
                    else (n-1)
  where
    os = sort as
    sums = scanl1 (+) os
    k = length $ takeWhile (<= x) sums


bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

tmain :: B.ByteString -> Int
tmain cont =
  let n : x : as = bsReadInts cont
  in solve n x as

main = putStrLn . show . tmain =<< B.getContents
