import sys

read=sys.stdin.buffer.read

readline=sys.stdin.buffer.readline

readlines=sys.stdin.buffer.readlines



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

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

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

#print(N,K)

#print("A:",A)

#print(F)



A.sort()

F.sort(reverse=True)

#print("A:",A)

#print("F:",F)



left=-1

right=10**18

#right=10**3



while left+1<right:

  mid=(left+right)//2

  tmp=[0]*(N)

  for i in range(N):

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

    

  if sum(tmp)<=K:

    right=mid

  else:

    left=mid

  #print("mid:",mid,",tmp:",tmp)

#print("left:",left,",mid:",mid,",right:",right)

print(right)
import sys

read=sys.stdin.buffer.read

readline=sys.stdin.buffer.readline

readlines=sys.stdin.buffer.readlines



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

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

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

#print(N,K)

#print("A:",A)

#print(F)



A.sort()

F.sort(reverse=True)

#print("A:",A)

#print("F:",F)



left=-1

right=10**18

#right=10**3



while left+1<right:

  mid=(left+right)//2

  tmp=0

  for i in range(N):

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

    

  if tmp<=K:

    right=mid

  else:

    left=mid

  #print("mid:",mid,",tmp:",tmp)

#print("left:",left,",mid:",mid,",right:",right)

print(right)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
F = list(map(int, readline().split()))
# print(N,K)
# print("A:",A)
# print(F)
A.sort()
F.sort(reverse=True)
# print("A:",A)
# print("F:",F)
left = -1
right = 10**18
# right=10**3
while left + 1 < right:
    mid = (left + right) // 2
    tmp = [0] * (N)
    for i in range(N):
        tmp[i] = max(A[i] - mid // F[i], 0)
    if sum(tmp) <= K:
        right = mid
    else:
        left = mid
    # print("mid:",mid,",tmp:",tmp)
# print("left:",left,",mid:",mid,",right:",right)
print(right)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
F = list(map(int, readline().split()))
# print(N,K)
# print("A:",A)
# print(F)
A.sort()
F.sort(reverse=True)
# print("A:",A)
# print("F:",F)
left = -1
right = 10**18
# right=10**3
while left + 1 < right:
    mid = (left + right) // 2
    tmp = 0
    for i in range(N):
        tmp += max(A[i] - mid // F[i], 0)
    if tmp <= K:
        right = mid
    else:
        left = mid
    # print("mid:",mid,",tmp:",tmp)
# print("left:",left,",mid:",mid,",right:",right)
print(right)

-    tmp = [0] * (N) +    tmp = 0 -        tmp[i] = max(A[i] - mid // F[i], 0) -    if sum(tmp) <= K: +        tmp += max(A[i] - mid // F[i], 0) +    if tmp <= K: