#include <bits/stdc++.h>
using namespace std;
int N, M, L, Q;
map<int, int> m[512];
long long A[200001], F[200001];
int is_ok(long long y, const int N, const int K) {
  long long cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] - y / F[i] > 0) {
      cnt += A[i] - y / F[i];
    }
  }
  if (cnt <= K) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int N;
  long long K;
  cin >> N >> K;
  long long max_val = 0LL;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> F[i];
    if (max_val < A[i] * F[i]) {
      max_val = A[i] * F[i];
    }
  }
  sort(A, A + N, greater<int>());
  sort(F, F + N);
  long long lb = -1, ub = 1e18;
  while (ub - lb > 1) {
    long long mid = (ub + lb) / 2;
    if (is_ok(mid, N, K)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  cout << ub << endl;
  return 0;
}
