#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[200000];
int F[200000];
bool solve(long long int m) {
  long long int n = 0;
  for (int i = 0; i < N; i++) {
    long long int a = A[i];
    long long int f = F[i];
    if (a * f > m) {
      long long int tmp;
      tmp = m / f;
      n += a - tmp;
    }
  }
  if (n > K)
    return false;
  else
    return true;
}
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];
  }
  sort(A, A + N);
  sort(F, F + N);
  long long int l = 0, r = LLONG_MAX;
  for (int i = 0; i <= 512; i++) {
    long long int mid = (l + r) / 2;
    bool ok = solve(mid);
    if (ok) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}
