#include <bits/stdc++.h>//glutonyの回答
#include <vector>
#include <iostream>
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
ll MAX_N = 2e5;
ll N; ll K;
vector<ll> A(MAX_N) vector<ll> F(MAX_N);


void input(){
    cin >> N >> K;
    rep(i, N)cin >> A[i];
    rep(i, N)cin >> F[i];
    return ;
}

void solve(){
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());
    ll l = -1, r = 1e12;
    while(l+1<r){
        ll c = (l+r)/2;
        bool ok = [&]{
            ll t = 0;
            rep(i, N) {
                t += max(0ll, A[i] - c/F[i]);
            }
            return t <= K;
        }();
        if(ok) r = c;else l = c;
    }
    cout << r << endl;
    


}

int main() {

    input();
    solve();
    return 0;
}