#include <bits/stdc++.h>
using namespace std;
int n, k, a[1000010], b[1000010], tmp1[1000010], tmp2[1000010];
bool check(long long x) {
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] * b[i] > x) {
      cnt += (a[i] - x / b[i]);
    }
  }
  if (cnt > k)
    return 0;
  else
    return 1;
}
int comp(int x, int y) { return x > y; }
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1, comp);
  long long l = 0, r = 1e12 + 10, ans = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans;
  return 0;
}
