def get(xs)
  i = 0
  q = nil

  while (i >= 0)
    t = xs[i]
    if (t.size == 2)
      # output only
      b, d = t
      if (d == 0)
        q = -1 # infinity
        xs[i] = [0, 0]
      else
        q = b/d
        xs[i] = [d, b - d*q]
      end
      i -= 1
    else
      a, b, c, d = t
      if (q) # input
        xs[i] = (q < 0) ? [b, d]: [b, a + b*q, d, c + d*q]
        q = nil
      elsif (c > 0 && d > 0 && a/c == b/d) # outpu
        q = b/d
        xs[i] = [c, d, a - c*q, b - d*q]
        i -= 1
      else
        # need input
        i += 1
      end
    end
  end

  return q
end

def is_zero?(xs)
  t = xs[0]
  t.size == 2 && t[0] == 0
end

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 = 0
  afs.each do |_, _, f| s += (af + 1)/f end
  s > l
}

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

l = -k
cf = [nil]
afs.each do |_, a, f|
  l += a
  cf.push([1,f,f,0]) # <> + 1/f
end

cf.push([0,1]) # <> + 0
cf[0] = [l,0,0,1] # l / <>

low = get(cf)
low += 1 unless (is_zero?(cf))

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

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