N, K = gets.chomp.split(" ").map(&:to_i);
A = gets.chomp.split(" ").map(&:to_i);
F = gets.chomp.split(" ").map(&:to_i);

aw = A.sort
fw = F.sort.reverse
R = []
(0...N).each{|i| R << [aw[i], fw[i], aw[i] * fw[i]]}

def sum_training_count(r, gool)
  r.select{|r| r[2] >= gool}.inject(0){|rst, r| rst + r[0] - gool / r[1]}
end

def binsearch(l, lc, h, hc, training, r)
  return h if h - l == 1
  lc = sum_training_count(r, l) if lc == -1
  hc = sum_training_count(r, h) if hc == -1
  m = (h - l)/2 + l
  mc = sum_training_count(r, m)
  if mc > training then
    return binsearch(m, mc, h, hc, training, r)
  else
    return binsearch(l, lc, m, mc, training, r)
  end
end

rmax = R.max_by{|r| r[2]}[2]
a_all = A.inject(:+)

if a_all <= K then
  puts 0
  exit
end

target = binsearch(0, a_all, rmax, -1, K, R)

puts target
