open Scanf ;;
open Printf ;;

let read_int () = scanf " %d" (fun x -> x) ;;

let rec powi a b = if b = 0 then 1 else a * powi a (b - 1);;

let list_sum a = List.fold_left (+) 0 a ;;

let rec read_ints n = if n = 0 then [] else read_int() :: read_ints (n - 1) ;;

let () =
  let n = read_int () in
  let k = read_int () in
  let a = read_ints n |> List.sort compare in
  let f = read_ints n |> List.sort compare |> List.rev in
  let rec search l r =
    if r - l = 1 then r
    else begin
      let m = (l + r) / 2 in
      let v = List.map2 (fun x y -> max 0 (x - m / y)) a f |> list_sum in
      if v <= k
        then search l m
        else search m r
    end
  in
  let ans = search (-1) (powi 10 12) in
  printf "%d\n" ans
  ;;

