n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
f=gets.split.map(&:to_i).sort.reverse
if a.inject(:+)<=k
  puts 0
  exit
end
l=[]
n.times do |i|
  l << [a[i]*f[i], f[i]]
end
l.sort!
s=0
t=l[-1][0]+1
while true
  if t-s==1
    puts t
    exit
  end
  c=(s+t)/2
  cnt=0
  l.each do |l0,l1|
    cnt+=(l0-c-1)/l1+1
  end
  if cnt<=k
    t=c
  else
    s=c
  end
end
