#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
ll a, b, c, i, j, l, m, n, ans, tmp, hoge, fuga, piyo;
unsigned long long k;
ll A[100000];
ll F[100000];
int desc(const void *a, const void *b) {
  ll aa = *(ll *)a;
  ll bb = *(ll *)b;
  ll c = bb - aa;
  if (c < 0) {
    return -1;
  } else if (c == 0) {
    return 0;
  } else {
    return 1;
  }
}
int asc(const void *a, const void *b) {
  ll aa = *(ll *)a;
  ll bb = *(ll *)b;
  ll c = aa - bb;
  if (c < 0) {
    return -1;
  } else if (c == 0) {
    return 0;
  } else {
    return 1;
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < (n); i++) cin >> A[i];
  for (int i = 0; i < (n); i++) cin >> F[i];
  qsort(A, n, sizeof(ll), desc);
  qsort(F, n, sizeof(ll), desc);
  for (int i = 0; i < n; i++) {
    if (A[i] <= k) {
      k = k - A[i];
      A[i] = 0;
    } else {
      A[i] = A[i] - k;
      k = 0;
    }
    if (k == 0) {
      break;
    }
  }
  qsort(A, n, sizeof(ll), asc);
  long long total = 0;
  for (int i = 0; i < n; i++) {
    total = max(total, A[i] * F[i]);
  }
  printf("%llu", total);
  return 0;
}
