#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void pp(T... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
bool go(vector<pair<long long int, long long int>> arr, long long int mid,
        long long int k) {
  for (long long int i = 0; i < arr.size(); i++) {
    if (arr[i].first * arr[i].second <= mid)
      continue;
    else {
      long long int rem = mid / arr[i].second;
      long long int to_sub = arr[i].first - rem;
      if (k >= to_sub)
        k -= to_sub;
      else
        return false;
    }
  }
  return true;
}
void solve() {
  long long int n, k;
  rd(n, k);
  vector<long long int> arr(n), p(n);
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  for (long long int i = 0; i < n; i++) {
    rd(p[i]);
  }
  if (sum <= k) {
    pp(0);
    return;
  }
  sort(arr.begin(), arr.end());
  sort(p.begin(), p.end(), greater<long long int>());
  long long int l = 0, h = arr[n - 1] * p[n - 1];
  vector<pair<long long int, long long int>> v;
  for (long long int i = 0; i < n; i++) {
    v.push_back({arr[i], p[i]});
  }
  long long int ans = h;
  while (l <= h) {
    long long int mid = l + (h - l) / 2;
    if (go(v, mid, k)) {
      ans = min(ans, mid);
      h = mid - 1;
    } else
      l = mid + 1;
  }
  pp(ans);
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
  return 0;
}
