# 時間内に解ける

import numpy as np

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

A = np.array(sorted(list(map(int, input().split()))))

F = np.array(sorted(list(map(int, input().split())), reverse=True))



left = - 1

right = 10**12



def f(x):

    #return np.maximum(0, A - x//F) .sum()<= K

    return A.sum() - np.minimum(A, x//F).sum()<= K



while right - left > 1:

    mid = (left + right)//2

    if f(mid):

        right = mid

    else:

        left = mid

    

print(right)
import numpy as np

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

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

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



A.sort(); F.sort(); F = F[::- 1]



left = - 1

right = 10**12



def f(x):

    l = x//F

    return A[A > l].sum() <= K + l[A > l].sum()



while right - left > 1:

    mid = (left + right)//2

    if f(mid):

        right = mid

    else:

        left = mid

    

print(right)
# 時間内に解ける
import numpy as np

N, K = list(map(int, input().split()))
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))
left = -1
right = 10**12


def f(x):
    # return np.maximum(0, A - x//F) .sum()<= K
    return A.sum() - np.minimum(A, x // F).sum() <= K


while right - left > 1:
    mid = (left + right) // 2
    if f(mid):
        right = mid
    else:
        left = mid
print(right)

import numpy as np

N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))
A.sort()
F.sort()
F = F[::-1]
left = -1
right = 10**12


def f(x):
    l = x // F
    return A[A > l].sum() <= K + l[A > l].sum()


while right - left > 1:
    mid = (left + right) // 2
    if f(mid):
        right = mid
    else:
        left = mid
print(right)

-# 時間内に解ける -A = np.array(sorted(list(map(int, input().split())))) -F = np.array(sorted(list(map(int, input().split())), reverse=True)) +A = np.array(list(map(int, input().split()))) +F = np.array(list(map(int, input().split()))) +A.sort() +F.sort() +F = F[::-1] -    # return np.maximum(0, A - x//F) .sum()<= K -    return A.sum() - np.minimum(A, x // F).sum() <= K +    l = x // F +    return A[A > l].sum() <= K + l[A > l].sum()