fun main(args: Array<String>) {
    abc144e()
}

private data class Member(val cost: Long, val food: Long)

fun abc144e() {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aList = readLine()!!.split(" ").map { it.toLong() }
        .sorted().toLongArray()
    val fList = readLine()!!.split(" ").map { it.toLong() }
        .sortedDescending().toLongArray()

    val members = aList.withIndex().map { Member(it.value, fList[it.index]) }

    // すべてのメンバーについてX以下とできるかどうかを二分探索する (条件:X以下にするために必要なK'<=K であること)
    var right = Long.MAX_VALUE / 2L
    var left = -1L
    while (right - left > 1L) {
        val mid = (left + right) / 2L
        val needTrainingSum = members.map { Math.max(0, it.cost - (mid / it.food)) }.sum()

        if (needTrainingSum <= k) right = mid else left = mid
    }

    println(right)
}

