N,K = gets.split.map &:to_i
A = gets.split.map(&:to_i).sort.reverse
F = gets.split.map(&:to_i).sort
MaxT = A.max * F.max
puts (0..MaxT).bsearch{ |t|
  (0...N).reduce(0){ |s,i|
    a = A[i] - (t / F[i])
    a > 0 ? s + a : s
  } <= K
}

