import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val K = in.next().toLong
  val _A = new Array[Int](N)
  val _F = new Array[Int](N)
  for (i <- 0 until N)
    _A(i) = in.next().toInt
  for (i <- 0 until N)
    _F(i) = in.next().toInt


  //
  val A = _A.sorted
  val F = _F.sorted.reverse



  def check(n: Long): Boolean = {
    var cnt = K
    breakable {
      for (i <- 0 until N) {
        val need = n / F(i)
        cnt -= Math.max(0L, A(i) - need)
      }
    }

    cnt >= 0
  }

  // 条件を満たす最小の値を返す
  def binarySearch(min: Long, max: Long): Long = {
    val mid: Long = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(min) match{
          case true  => min
          case false => max
        }
      case _ =>
        (check(mid)) match{
          case true  => binarySearch(min, mid)
          case false => binarySearch(mid, max)
        }
    }
  }



  val ans = binarySearch(0L, 1e12.toLong)

  println(ans)
}


class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}
