import Data.List
import Data.Char
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  [n, k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  as <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  fs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine 
  print $ binarySearch k (VU.fromList $ sort as) (VU.fromList $ reverse $ sort fs) (-1, 1100000000000000000)

binarySearch :: Int -> VU.Vector Int -> VU.Vector Int -> (Int, Int) -> Int
binarySearch k as fs (l, r)
  | r - l <= 1 = r
  | otherwise = if check mid
                  then binarySearch k as fs (l, mid)
                  else binarySearch k as fs (mid, r)
                where 
                  mid = (l + r) `div` 2
                  check :: Int -> Bool
                  check x = (VU.sum $ VU.filter (> 0) $ VU.zipWith (\a f -> a - x `div` f) as fs) <= k
                    