n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
fs = gets.split.map(&:to_i)
 
if (as.sum <= k)
  p(0)
  exit
end

afs = as.sort.zip(fs.sort.reverse).map do |a, f| [a*f, a, f] end.sort.reverse
afs << [0, 0, 1] # sentinel

xs = (0..n-1).map do |i|
  d = afs[i][0] - afs[i+1][0]
  afs[i] + [d]
end

v = 0
low = 0
krest = k

xs.each do |af, a, f, d|
  v += Rational(1, f)
  reset = krest - d * v
  if (reset <= 0)
    low = af - krest / v
    break
  end
  krest = reset
end

ys = xs.map do |af, a, f, d| 
  final_a = [(low / f).ceil, a].min
  k -= a - final_a
  final_a * f
end

p(ys.sort.reverse[k])