open System
let tmp = Console.ReadLine().Split(' ')
let N = int (tmp.[0])
let K = int64 (tmp.[1])

let tmp_A = Array.map int64 (Console.ReadLine().Split(' '))
let tmp_F = Array.map int64 (Console.ReadLine().Split(' '))

let A = Array.sort tmp_A
let F = Array.rev (Array.sort tmp_F)

let required_training target a f=
    if a * f <= target then 0L
    else 
      let diff = a * f - target
      if diff % f = 0L then diff / f
      else diff / f + 1L
     
let rec f L R =
  if L >= R - 1L then R
  else
    let mid = (L + R) / 2L
    if K >= Array.sum (Array.map2 (required_training mid) A F) then f L mid
    else f mid R

if Array.sum (Array.map2 (required_training 0L) A F) <= K then
  Console.WriteLine(0)
else
  Console.WriteLine(f 0L (Array.max (Array.map2 (fun x y -> x * y) A F)))
