#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool f = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return f ? -x : x;
}
const int maxn = 1e6 + 3;
int a[maxn], f[maxn], n;
long long maxa = -1, maxf = -1, k;
bool chk(long long x) {
  long long tmp = k;
  for (register int i = (1), i_end = (n); i <= i_end; ++i) {
    long long qw = x / f[n - i + 1];
    if (a[i] > qw) tmp -= (a[i] - qw);
  }
  if (tmp < 0)
    return false;
  else
    return true;
}
int main() {
  n = read(), k = read();
  for (register int i = (1), i_end = (n); i <= i_end; ++i) a[i] = read();
  for (register int i = (1), i_end = (n); i <= i_end; ++i) f[i] = read();
  sort(a + 1, a + n + 1);
  sort(f + 1, f + n + 1);
  long long l = 0, r = (long long)a[n] * f[n], ans = 0;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (chk(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  cout << ans << endl;
  return 0;
}
