open System

let N,K = stdin.ReadLine().Split()|>fun c -> int c.[0],int64 c.[1]
let A = stdin.ReadLine().Split()|>Array.map int64|>Array.sort
let F = stdin.ReadLine().Split()|>Array.map int64|>Array.sort
[<EntryPoint>]
let main argv =
    let t = [|for i in [0..N-1] do yield A.[N-1-i]*F.[i]|]
    let mutable l = -(1L)
    let mutable r=1e13|>int64

    while r-l>1L do
        let c = ((r+l)/2L)
        let mutable sum =0L
        for i in [0..N-1] do
            sum <- (if t.[i]>c then ((t.[i] - c + F.[i] - (1L))/F.[i]) else 0L) + sum 

        match sum<=K with
        |true -> r<-c
        |false -> l<-c

    printfn "%d" r
    0
