#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e13;

int main(){
  ll n; ll k;
  cin >> n >> k;
  ll a[n]; ll f[n];
  rep(i,n)  cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a,a+n); sort(f,f+n,greater<ll>()); 
  ll l = -1, r = INF;
  while(r-l > 1) {
    ll m = (r+l)/2;
    ll t = 0;
    ll b[n];
    rep(i,n) b[i] = (m/f[i]);
    bool can = true;
    ll z = k;
    rep(i,n) {
      if(a[i] > b[i]) z -= a[i] - b[i];
    }
    if(z >= 0) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}