#include <bits/stdc++.h>
using namespace std;
long long int MAX_N = 2e5;
long long int N;
long long int K;
vector<long long int> A(MAX_N);
vector<long long int> F(MAX_N);
void input() {
  cin >> N >> K;
  for (int(i) = 0; (i) < (N); (i)++) cin >> A[i];
  for (int(i) = 0; (i) < (N); (i)++) cin >> F[i];
  return;
}
void solve() {
  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  long long int l = -1, r = 1e12;
  while (l + 1 < r) {
    long long int c = (l + r) / 2;
    bool ok = [&] {
      long long int t = 0;
      for (int(i) = 0; (i) < (N); (i)++) {
        t += max(0ll, A[i] - c / F[i]);
      }
      return t <= K;
    }();
    if (ok)
      r = c;
    else
      l = c;
  }
  cout << r << endl;
}
int main() {
  input();
  solve();
  return 0;
}
