#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> f[i];
  }
  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<int>());
  vector<ll> af(n);
  for (int i = 0; i < n; i++) {
    af[i] = a[i] * f[i];
  }
  ll l = -1, r = 1e12;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    ll num = 0;
    for (int i = 0; i < n; i++) {
      if (af[i] > m) {
        ll tmp = a[i] - m / f[i];
        num += tmp;
      }
    }
    if (num <= k) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;
  return 0;
}
