import java.util.*

fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toLong()}
    val A = readLine()!!.split(" ").map{it.toLong()}.sorted().toTypedArray()
    val F = readLine()!!.split(" ").map{it.toLong()}.sortedDescending()

    var l = -1L
    var u = 1e13.toLong()

    while (u - l > 1) {
        val c = (l + u) / 2

        var k = K
        var ok = true
        for (i in A.indices) {
            val d = Math.max(A[i] - c / F[i], 0L)
            if (d > k) {
                ok = false
                break
            } else {
                k -= d
            }
        }

        if (ok) {
            u = c
        } else {
            l = c
        }
    }

    println(u)
}
