N, K = list(map(int, input().split()))

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

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



A = sorted(A)

F = sorted(F, reverse=True)



l = -1 # 絶対にfalse

r = 10**12+5

while (l+1<r):

  c = (l+r)//2

  s = 0

  for i in range(N):

    s += max(0, A[i]-(c//F[i]))

  if s <= K:

    r = c

  else:

    l = c



print(r)
N, K = list(map(int, input().split()))

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

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



A = sorted(A)

F = sorted(F, reverse=True)



l = -1

r = 10**12+5



while (l+1<r):

  c = (l+r)//2

  tmp = 0

  for i in range(N):

    tmp += max(0, A[i]-(c//F[i]))

  

  if tmp <= K:

    r = c

  else:

    l = c



print(r)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A = sorted(A)
F = sorted(F, reverse=True)
l = -1  # 絶対にfalse
r = 10**12 + 5
while l + 1 < r:
    c = (l + r) // 2
    s = 0
    for i in range(N):
        s += max(0, A[i] - (c // F[i]))
    if s <= K:
        r = c
    else:
        l = c
print(r)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A = sorted(A)
F = sorted(F, reverse=True)
l = -1
r = 10**12 + 5
while l + 1 < r:
    c = (l + r) // 2
    tmp = 0
    for i in range(N):
        tmp += max(0, A[i] - (c // F[i]))
    if tmp <= K:
        r = c
    else:
        l = c
print(r)

-l = -1  # 絶対にfalse +l = -1 -    s = 0 +    tmp = 0 -        s += max(0, A[i] - (c // F[i])) -    if s <= K: +        tmp += max(0, A[i] - (c // F[i])) +    if tmp <= K: