#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  scanf("%lld %lld", &n, &k);
  long long int a[n], f[n];
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &f[i]);
  }
  sort(a, a + n);
  sort(f, f + n);
  reverse(f, f + n);
  long long int l = 0, r = 1000000000001;
  while (l < r) {
    long long int mid = (l + r) / 2, c = 0;
    for (long long int i = 0; i < n; i++) {
      c += a[i] - mid / f[i];
    }
    if (c <= k) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  printf("%lld\n", l);
}
