import Data.Function
import Data.Int
import Data.List
import qualified Data.Vector as V

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  l3 <- getLine
  let [n, k] = map read $ words l1 :: [Int64]
      as = sort $ map read $ words l2 :: [Int64]
      ws = reverse $ sort $ map read $ words l3 :: [Int64]
      va = V.fromList as
      vw = V.fromList ws
      --v = V.zip va vw
      v = V.fromList $ reverse $ sortOn (uncurry (*)) $ zip as ws

  if V.sum va <= k
    then print 0
    else do
      let v' = f n v k
      print $ uncurry (*) $ V.maximumBy (compare `on` uncurry (*)) v'

f n v k =
  if n == 1 then V.fromList [(max 0 $ a1 - k, w1)]
  else if k' <= k
    then f n (insert' (uncurry (*)) (a1 - k', w1) v2) $ k - k'
    else insert' (uncurry (*)) (a1 - k, w1) v2
  where
    (v1, v2) = V.splitAt 1 v
    (a1, w1) = V.head v1
    (a2, w2) = V.head v2
    k' = (a1*w1 - a2*w2)`div`w1 + 1

insert' f' e v = v1 V.++ V.singleton e V.++ v2
  where
    (v1, v2) = V.partition ((>f' e) . f') v