# E

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

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

a.sort()

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

f.sort(reverse=True)

x=1

i=0

while i>=0:

    cnt=0

    for j in range(n):

        cnt+=max(0,a[j]-x//f[j])

    if cnt>k:

        i+=1

        x=2**i

    else:

        break

while i>0:

    cnt=0

    for j in range(n):

        cnt+=max(0,a[j]-x//f[j])

    if cnt>k:

        i-=1

        x+=2**i

    else:

        i-=1

        x-=2**i

y=x-1

cnt=0

for j in range(n):

    cnt+=max(0,a[j]-y//f[j])

if cnt<=k:

    print(y)

else:

    cnt=0

    for j in range(n):

        cnt+=max(0,a[j]-x//f[j])

    if cnt<=k:

        print(x)

    else:

        print((x+1))
def f(x):

    cnt=0

    for i in range(N):

        num=x//F[i]

        if A[i]>num:

            cnt+=A[i]-num

    return cnt



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)



low=0

high=10**12+1

while high-low>0:

    mid=(high+low)//2

    xxx=f(mid)

    if xxx<=K:

        high=mid

    else:

        if low==mid:

            low=high

        else:

            low=mid



print(low)
# E
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
f = list(map(int, input().split()))
f.sort(reverse=True)
x = 1
i = 0
while i >= 0:
    cnt = 0
    for j in range(n):
        cnt += max(0, a[j] - x // f[j])
    if cnt > k:
        i += 1
        x = 2**i
    else:
        break
while i > 0:
    cnt = 0
    for j in range(n):
        cnt += max(0, a[j] - x // f[j])
    if cnt > k:
        i -= 1
        x += 2**i
    else:
        i -= 1
        x -= 2**i
y = x - 1
cnt = 0
for j in range(n):
    cnt += max(0, a[j] - y // f[j])
if cnt <= k:
    print(y)
else:
    cnt = 0
    for j in range(n):
        cnt += max(0, a[j] - x // f[j])
    if cnt <= k:
        print(x)
    else:
        print((x + 1))

def f(x):
    cnt = 0
    for i in range(N):
        num = x // F[i]
        if A[i] > num:
            cnt += A[i] - num
    return cnt


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)
low = 0
high = 10**12 + 1
while high - low > 0:
    mid = (high + low) // 2
    xxx = f(mid)
    if xxx <= K:
        high = mid
    else:
        if low == mid:
            low = high
        else:
            low = mid
print(low)

-# E -n, k = list(map(int, input().split())) -a = list(map(int, input().split())) -a.sort() -f = list(map(int, input().split())) -f.sort(reverse=True) -x = 1 -i = 0 -while i >= 0: +def f(x): -    for j in range(n): -        cnt += max(0, a[j] - x // f[j]) -    if cnt > k: -        i += 1 -        x = 2**i +    for i in range(N): +        num = x // F[i] +        if A[i] > num: +            cnt += A[i] - num +    return cnt + + +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) +low = 0 +high = 10**12 + 1 +while high - low > 0: +    mid = (high + low) // 2 +    xxx = f(mid) +    if xxx <= K: +        high = mid -        break -while i > 0: -    cnt = 0 -    for j in range(n): -        cnt += max(0, a[j] - x // f[j]) -    if cnt > k: -        i -= 1 -        x += 2**i -    else: -        i -= 1 -        x -= 2**i -y = x - 1 -cnt = 0 -for j in range(n): -    cnt += max(0, a[j] - y // f[j]) -if cnt <= k: -    print(y) -else: -    cnt = 0 -    for j in range(n): -        cnt += max(0, a[j] - x // f[j]) -    if cnt <= k: -        print(x) -    else: -        print((x + 1)) +        if low == mid: +            low = high +        else: +            low = mid +print(low)