import numpy as np

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

AA=np.sort(A)
BB=np.sort(B)[::-1]
S=np.sum(A)
CC=np.array([AA[i]*BB[i] for i in range(N)])
if K>S:
    K=S

for j in range(K):
    m=np.argmax(CC)
    AA[m]-=1
    CC[m]=AA[m]*BB[m]
print(np.max(CC))