// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

#define rep(i, n) for (ll i = 0; i < n; i++)

#define FOR(i, a, b) for (ll i = a; i < b; i++)

#define len(v) ll(v.size())

#define fi first

#define se second



template <class T>

void cout_vec(const vector<T> &vec){

  for(auto itr:vec) cout<<itr<<' ';

  cout<<endl;

}



template <class T>

void cout_vec2(const vector<vector<T>> &vec){

  rep(i,vec.size()){

    rep(j,vec[i].size()){

      cout<<vec[i][j]<<' ';

    }

    cout<<endl;

  }

}



typedef pair<ll,ll> P;

const ll mod=1e9+7;

const ll inf=1e15;



ll n,k;

vector<ll> a(200010),f(200010);



bool solve(ll x){

  ll ret=k;

  rep(i,n){

    if(a[i]*f[i]<=x) continue;

    ll now=(a[i]*f[i]-x+f[i]-1)/f[i];

    if(now<=ret) ret-=now;

    else{

      return false;

    }

  }

  return true;

}





int main(){

  cin.tie(0);

  ios::sync_with_stdio(false);

  cin>>n>>k;

  rep(i,n) cin>>a[i];

  rep(i,n) cin>>f[i];

  sort(begin(a),begin(a)+n);

  sort(begin(f),begin(f)+n,greater<ll>());

  ll ans=0;

  ll high=1e18,low=-1,mid;

  while(high-low>1){

    mid=(high+low)/2;

    if(solve(mid)) high=mid;

    else low=mid;

  }

  cout<<high<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.164213851619573x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

typedef pair<ll,ll> P;

typedef pair<int,int> Pi;

#define rep(i,n) for(ll i=0;i<n;i++)

#define FOR(i,a,b) for(ll i=a;i<b;i++)

#define fi first

#define se second

#define endl "\n"



template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}

template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}

template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}

template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}

template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}

template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}

template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}



const ll mod=1'000'000'007;

const ll inf=1'000'000'000'000'000'00;

const int INF=1'000'000'000;

const double EPS=1e-10;

const double PI=acos(-1);



int main(){

    cin.tie(0);ios::sync_with_stdio(false);

    ll n,k;

    cin>>n>>k;

    vector<ll> a(n),f(n);

    rep(i,n){

        cin>>a[i];

    }

    rep(i,n){

        cin>>f[i];

    }

    sort(begin(a),end(a));

    sort(begin(f),end(f),greater<ll>());

    auto solve=[&](ll x){

        ll cnt=0;

        rep(i,n){

            if(a[i]*f[i]<=x) continue;

            cnt+=a[i]-x/f[i];

        }

        return cnt<=k;

    };

    ll ok=inf,ng=-1,mid;

    while(ok-ng>1){

        mid=(ok+ng)/2;

        if(solve(mid)) ok=mid;

        else ng=mid;

    }

    cout<<ok<<endl;

}