let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let rec binary_search left right eval =
  if right - left <= 1 then right
  else
    let mid = (left + right) / 2 in
    if eval mid then binary_search left mid eval
    else binary_search mid right eval

let eval a f n k value =
  let require = ref 0 in
  let _ =
    for i = 0 to n-1 do
      require := !require + max 0 (a.(i) - value / f.(i))
    done in
  !require <= k

let init_val = int_of_float 1e12

let solve () =
  let n = scan_int() and k = scan_int() in
  let a = scan_array n scan_int in
  let f = scan_array n scan_int in
  let _ = Array.fast_sort (fun x y -> x - y) a in
  let _ = Array.fast_sort (fun x y -> y - x) f in
  binary_search (-1) init_val (eval a f n k)


let () = print_int (solve())