#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  long long l = -1, r = 1e12;
  while (l + 1 < r) {
    long long c = (l + r) / 2;
    bool ok = [&] {
      long long s = 0;
      for (int i = 0; i < (n); i++) {
        s += max(0ll, a[i] - c / f[i]);
      }
      return s <= k;
    }();
    if (ok)
      r = c;
    else
      l = c;
  }
  cout << r << endl;
  return 0;
}
