n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
fs = gets.split.map(&:to_i)

sum_a = as.inject(:+)

if (sum_a <= k)
  p 0
  exit
end

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

l = sum_a - k

m = (0...n).bsearch {|i|
  af = afs[i][0]
  s = afs.inject(0) do |r, item| r + (af + 1)/item[2] end
  s > l
}

afs = afs.drop(m)
n -= m

l = -k
v = 0
 afs.each do |_, a, f|
  l += a
  v += Rational(1, f)
end

low = (l / v).ceil

xs = afs.map do |_, _, f|
  final_a = (low - 1) / f + 1
  l -= final_a
  final_a * f
end

p xs.flatten.sort.reverse[-l]