import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord

main = sol <$> get <*> get >>= print

get = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

sol [_,k] as = f k ps
  where
  bs = sortBy (flip compare) as
  ps = zip bs $ scanr1 (+) bs
  f _ []   = 0
  f k ps@((b,s):ps')
    | b>=k = f k ps'
    | s>=k = f (k-b) ps'
    | True = length ps