// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e3;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
// vvi adj(maxn);
// vb vis(maxn,false);
// ll ans;
// ll dfs(ll u,ll x){
//     vis[u]=true;
//     for(auto v:adj[u]){
//         if(!vis[v]){
//             ans++;
//             if(ans==x)return v;
//             dfs(u,x);
//         }
//     }
//     return -1;
// }
ll fact(ll x){
    ll ans=1;
    fr(i,1,x)ans*=i;
    return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    ll ans=fact(n);
    ans/=fact(r);
    ans/=fact(n-r);
    return ans;
}
vi a,b;
ll n,k;
bool check(ll x){
    ll cnt=0;
    fr1(i,n){
        if(a[i]*b[i]>x){
            if(x%b[i]==0)cnt+=(a[i]*b[i]-x)/b[i];
            else {
                cnt+=(a[i]*b[i]-x)/b[i];
                cnt++;
            }
        }
    }
    return cnt<=k;
}
int main(){
    
    fio;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif  
    cin>>n>>k;
    a.resize(n);
    b.resize(n);
    fr1(i,n)cin>>a[i];
    fr1(i,n)cin>>b[i];
    sortva(a);
    sortvd(b);
    ll l=0,h=1e12;
    while(l<h){
        ll mid=(l+h)/2;
        if(check(mid))h=mid;
        else l=mid+1;
    }
    cout<<l;
    return 0;
}

Measured memory_bytes: 3328