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