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

  var min = -1L
  var max = 1000000000000L
  while (min + 1 < max) {
    val mid = (min + max) / 2
    var sum = 0L
    for (i in 0 until N.toInt()) {
      if (A[i] * F[i] > mid) sum += (A[i] - mid / F[i])
    }
    if (sum <= K) max = mid else min = mid
  }
  println(max)
}
