#include <bits/stdc++.h>
int main() {
  long long n;
  long long k;
  long long a[200000];
  long long f[200000];
  std::cin >> n;
  std::cin >> k;
  for (long long i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  for (long long i = 0; i < n; ++i) {
    std::cin >> f[i];
  }
  std::sort(a, a + n);
  std::sort(f, f + n, std::greater<long long>());
  for (long long i = 0; i < k; ++i) {
    long long max = 0;
    long long maxJ;
    for (long long j = 0; j < n; ++j) {
      long long p = a[j] * f[j];
      if (max < p) {
        maxJ = j;
        max = p;
      }
    }
    if (max == 0) {
      break;
    } else {
      --a[maxJ];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long p = a[i] * f[i];
    if (ans < p) {
      ans = p;
    }
  }
  std::cout << ans;
  return 0;
}
