import math 

def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

def costsum(x,y):
    siguma =0
    Asort = quick_sort(x)
    Fsort = quick_sort(y)
    for i in range(N):
        siguma = siguma + Asort[i]*Fsort[N-i-1]
    return siguma
def maxseki(x,y):
    seki = 0
    count = 0
    Asort = quick_sort(x)
    Fsort = quick_sort(y)
    for i in range(N):
        if seki < Asort[i]*Fsort[N-i-1]:
            seki = Asort[i]*Fsort[N-i-1]
            count = i
    return count

input1 = input()
input2 = input()
input3 = input()

hairetu1 = input1.split()
hairetu2 = input2.split()
hairetu3 = input3.split()
N = int(hairetu1[0])
K = int(hairetu1[1])
A = [int(s) for s in hairetu2] 
F = [int(t) for t in hairetu3]

Asort = quick_sort(A)
Fsort = quick_sort(F)

for i in range(K):
    s=maxseki(Asort,Fsort)
    Asort[s]=Asort[s]-1


P = maxseki(Asort,Fsort)
maxcost = Asort[P]*Fsort[N-P-1]
if maxcost < 0:
    maxcost =0
print (maxcost)


    