fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong).sorted()
    val fList = readLine()!!.split(' ').map(String::toLong).sortedDescending()
    if (aList.sum() <= k) {
        println(0)
        return
    }

    fun checkCanReach(v: Long): Boolean {
        var sum = 0L
        for (i in 0 until n.toInt()) {
            val ma = v / fList[i]
            if (ma < aList[i]) sum += aList[i] - ma
            if (sum > k) return false
        }
        return true
    }
//二分探索
    var targetIndex = 1L shl 60
    for (i in 59 downTo 0) {
        val currentIndex = targetIndex - (1L shl i)
        if (checkCanReach(currentIndex)) {
            targetIndex -= 1L shl i
        }
    }
    println(targetIndex)
}