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

abilities=sorted(list(map(int,input().split())))

foods=sorted(list(map(int,input().split())),reverse=True)



if sum(abilities)<=k:

  print((0))

  exit()

  

def check(score):

  ret=0

  for a,f in zip(abilities,foods):

    ret+=max(0,(a*f-score+f-1)//f)

  return ret<=k



ok=10**12+1

ng=0

for _ in range(50):

  mid=(ok+ng)//2

  if check(mid):

    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=True)



def check(s):

  ret=0

  for i,j in zip(a,f):

    ret+=max(0,i-s//j)

  return ret<=k



ok=10**12+1

ng=-1

while ok-ng>1:

  mid=(ok+ng)//2

  if check(mid):

    ok=mid

  else:

    ng=mid

print(ok)
n, k = list(map(int, input().split()))
abilities = sorted(list(map(int, input().split())))
foods = sorted(list(map(int, input().split())), reverse=True)
if sum(abilities) <= k:
    print((0))
    exit()


def check(score):
    ret = 0
    for a, f in zip(abilities, foods):
        ret += max(0, (a * f - score + f - 1) // f)
    return ret <= k


ok = 10**12 + 1
ng = 0
for _ in range(50):
    mid = (ok + ng) // 2
    if check(mid):
        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=True)


def check(s):
    ret = 0
    for i, j in zip(a, f):
        ret += max(0, i - s // j)
    return ret <= k


ok = 10**12 + 1
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok)

-abilities = sorted(list(map(int, input().split()))) -foods = sorted(list(map(int, input().split())), reverse=True) -if sum(abilities) <= k: -    print((0)) -    exit() +a = list(map(int, input().split())) +f = list(map(int, input().split())) +a.sort() +f.sort(reverse=True) -def check(score): +def check(s): -    for a, f in zip(abilities, foods): -        ret += max(0, (a * f - score + f - 1) // f) +    for i, j in zip(a, f): +        ret += max(0, i - s // j) -ng = 0 -for _ in range(50): +ng = -1 +while ok - ng > 1: