import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
g :: Int -> [(Int,Int)] -> Int -> Bool
g x b k = (sum $ map (\(c,d) -> if x < c * d then c - (x `div` d) else 0) b) <= k

h :: Int -> Int -> [(Int,Int)] -> Int -> Int
h m n b k
    | m == n = m
    | g l b k = h m l b k
    | otherwise = h (l+1) n b k
    where l = (m+n)`div`2

main = do
    [n,k] <- (BS.getLine >>= return . (map (fst . fromJust . BS.readInt)) . BS.words) :: IO [Int]
    a <- BS.getLine >>= return . sort . (map (fst . fromJust . BS.readInt)) . BS.words
    f <- BS.getLine >>= return . reverse . sort . (map (fst . fromJust . BS.readInt)) . BS.words
    let b = zip a f
    putStrLn $ show $ h 0 (maximum $ map (\(c,d)->c*d) b) b k