#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
signed main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> a(N), f(N);
  for (long long i = 0; i < N; i++) cin >> a[i];
  for (long long i = 0; i < N; i++) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  long long l = -1, r = LINF;
  while (r - l > 1) {
    long long m = (r + l) >> 1;
    long long cnt = 0;
    for (long long i = 0; i < N; i++) {
      if (a[i] * f[i] > m) {
        cnt += (a[i] * f[i] - m) / f[i];
        if ((a[i] * f[i] - m) % f[i]) cnt++;
      }
    }
    if (cnt > K)
      l = m;
    else
      r = m;
  }
  cout << r << endl;
}
