n,k=list(map(int,input().split()))

a=list(map(int,input().split()))

f=list(map(int,input().split()))

a.sort()

f.sort()

ok=a[-1]*f[-1]

ng=0

if sum(a)<=k:print((0));exit()

ma=ok

while ng+1!=ok:

  mid=(ok+ng)//2

  b=[mid//i for i in f]

  b.sort()

  h=0

  for i in range(n):h+=max(0,a[i]-b[i])

  if h<=k:ok=mid

  else:ng=mid

print(ok)
n,k=list(map(int,input().split()))

a=list(map(int,input().split()))

f=list(map(int,input().split()))

a.sort()

f.sort(reverse=1)

su=ok=ng=0

for i in range(n):

  ok=max(ok,a[i]*f[i])

  su+=a[i]

if su<=k:print((0));exit()

while ng+1!=ok:

  mid=(ok+ng)//2

  b=[mid//i for i in f]

  b.sort()

  h=0

  for i in range(n):h+=max(0,a[i]-b[i])

  if h<=k:ok=mid

  else:ng=mid

print(ok)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort()
ok = a[-1] * f[-1]
ng = 0
if sum(a) <= k:
    print((0))
    exit()
ma = ok
while ng + 1 != ok:
    mid = (ok + ng) // 2
    b = [mid // i for i in f]
    b.sort()
    h = 0
    for i in range(n):
        h += max(0, a[i] - b[i])
    if h <= k:
        ok = mid
    else:
        ng = mid
print(ok)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=1)
su = ok = ng = 0
for i in range(n):
    ok = max(ok, a[i] * f[i])
    su += a[i]
if su <= k:
    print((0))
    exit()
while ng + 1 != ok:
    mid = (ok + ng) // 2
    b = [mid // i for i in f]
    b.sort()
    h = 0
    for i in range(n):
        h += max(0, a[i] - b[i])
    if h <= k:
        ok = mid
    else:
        ng = mid
print(ok)

-f.sort() -ok = a[-1] * f[-1] -ng = 0 -if sum(a) <= k: +f.sort(reverse=1) +su = ok = ng = 0 +for i in range(n): +    ok = max(ok, a[i] * f[i]) +    su += a[i] +if su <= k: -ma = ok