fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map { it.toLong() }
    val AArr = readInputLine().split(" ").map { it.toLong() }.sorted().toLongArray()
    val BArr = readInputLine().split(" ").map { it.toLong() }.sortedDescending().toLongArray()

    if (N == 1L) {
        println(Math.max(0L, AArr[0]) * BArr[0])
        return
    }
    
    var lb = -1L
    var ub = 1000000000000L
    
    while (ub - lb > 1L) {
        val mid = (lb + ub) / 2L
        
        var cnt = 0L
        var ok = true
        
        for (i in 0 until N.toInt()) {
            cnt += Math.max(0L, Math.ceil((AArr[i].toDouble() * BArr[i].toDouble() - mid) / BArr[i]).toLong())
            if (cnt > K) {
                ok = false
                break
            }
        }
        
        if (ok) {
            ub = mid
        } else {
            lb = mid
        }
    }
    
    println(ub)
}

fun readInputLine(): String {
    return readLine()!!
}
