"use strict"

const nkaf = require('fs').readFileSync('/dev/stdin', 'UTF-8').split('\n')
const NK = nkaf[0].split(' ')
const N = +NK[0]
const K = +NK[1]
let A = nkaf[1].split(' ').map(x=>+x).sort((a,b)=>b-a)
let F = nkaf[1].split(' ').map(x=>+x).sort((a,b)=>b-a)

for(let i=0;i<K;i++){
    A[0]--
    A = a.sort((a,b)=>b-a)
}

A = A.sort((a,b) => a- b)

let result = []
F.forEach((element, index) => {
    if(A[index] > 0){
        result.push(element * A[index])
    }
})

console.log(Math.max(...result))