from heapq import heappop, heappush

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

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

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



def ok(x):

    cnt = 0

    for i in range(N):

        current = A[i] * F[i]

        if current > x:

            cnt += -(-(current - x) // F[i])

            

    return cnt <= K



A.sort()

F.sort(reverse=True)

lb = 0

ub = 10 ** 12 + 1



while ub - lb > 1:

    mid = (lb + ub) // 2

    

    if ok(mid):

        ub = mid

    else:

        lb = mid

        

if sum(A) <= K:

    print((0))

else:

    print(ub)





from heapq import heappush, heappop



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

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

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



F.sort()

x = [a * b for a, b in zip(F, sorted(A, reverse=True))]



ub = max(x)

lb = 0

while ub - lb > 1:

    mid = (ub + lb) // 2

    res = 0

    for i in range(N):

        tmp = max(0, x[i] - mid)

        res += -(-tmp // F[i])



    if res <= K:

        ub = mid

    else:

        lb = mid



if sum(A) <= K:

    print((0))

else:

    print(ub)



from heapq import heappop, heappush

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


def ok(x):
    cnt = 0
    for i in range(N):
        current = A[i] * F[i]
        if current > x:
            cnt += -(-(current - x) // F[i])
    return cnt <= K


A.sort()
F.sort(reverse=True)
lb = 0
ub = 10**12 + 1
while ub - lb > 1:
    mid = (lb + ub) // 2
    if ok(mid):
        ub = mid
    else:
        lb = mid
if sum(A) <= K:
    print((0))
else:
    print(ub)

from heapq import heappush, heappop

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
F.sort()
x = [a * b for a, b in zip(F, sorted(A, reverse=True))]
ub = max(x)
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2
    res = 0
    for i in range(N):
        tmp = max(0, x[i] - mid)
        res += -(-tmp // F[i])
    if res <= K:
        ub = mid
    else:
        lb = mid
if sum(A) <= K:
    print((0))
else:
    print(ub)

-from heapq import heappop, heappush +from heapq import heappush, heappop - - -def ok(x): -    cnt = 0 +F.sort() +x = [a * b for a, b in zip(F, sorted(A, reverse=True))] +ub = max(x) +lb = 0 +while ub - lb > 1: +    mid = (ub + lb) // 2 +    res = 0 -        current = A[i] * F[i] -        if current > x: -            cnt += -(-(current - x) // F[i]) -    return cnt <= K - - -A.sort() -F.sort(reverse=True) -lb = 0 -ub = 10**12 + 1 -while ub - lb > 1: -    mid = (lb + ub) // 2 -    if ok(mid): +        tmp = max(0, x[i] - mid) +        res += -(-tmp // F[i]) +    if res <= K: