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 rec read_ints n = 
  let a = Array.make n 0 in
  for i = 0 to n - 1 do
    a.(i) <- read_int ()
  done;
  a
  ;;

let () =
  let n = read_int () in
  let k = read_int () in
  let a = read_ints n in
  let f = read_ints n in
  Array.sort (fun x y -> compare x y) a;
  Array.sort (fun x y -> compare y x) f;
  let rec search l r =
    if r - l = 1 then r
    else begin
      let m = (l + r) / 2 in
      let sum = ref 0 in
      for i = 0 to n - 1 do
        let v = max 0 (a.(i) - m / f.(i)) in
        sum := !sum + v
      done;
      if !sum <= k
        then search l m
        else search m r
    end
  in
  let ans = search (-1) (powi 10 12) in
  printf "%d\n" ans
  ;;

