#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
const int MOD = (int)1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};
long long n, k;
vector<long long> A;
vector<long long> F;
bool can(long long t) {
  vector<long long> B(n);
  for (int i = (0); i < (n); ++i) {
    B[i] = t / F[n - 1 - i];
  }
  long long nk = 0;
  for (int i = (0); i < (n); ++i) {
    nk += max(A[i] - B[i], 0LL);
  }
  return nk <= k;
}
long long solve() {
  long long t = 0;
  for (int i = (0); i < (n); ++i) {
    t = max(t, A[i] * F[n - 1 - i]);
  }
  long long left = 0;
  long long right = t;
  long long mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (can(mid)) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return left;
}
int main(void) {
  cin >> n >> k;
  A.resize(n);
  F.resize(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).begin(), (F).end());
  printf("%lld\n", solve());
  return 0;
}
