let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let a = Array.of_list (split (read_line ())) in
        let f = Array.of_list (split (read_line ())) in
        let () = Array.sort compare a in
        let () = Array.sort compare f in
        let init =
            let rec loop i acc =
                if i = n then acc else loop (i + 1) (max acc (a.(i) * f.(i)))
            in
            loop 0 0
        in
        let calc m =
            let rec loop i acc =
                if i = n then acc else
                    loop (i + 1) (acc + max 0 (a.(n - 1 - i) - m / f.(i)))
            in
            loop 0 0
        in
        let rec bin left right =
            if left = right then left else
                let m = (left + right) / 2 in
                let cost = calc m in
                if cost <= k then bin left m else bin (m + 1) right
        in
        let r = bin 0 init in
        Printf.printf "%d\n" r
    in
    main ()