#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> f[i];
    sort(a.begin(), a.end(), greater<long long>());
    sort(f.begin(), f.end());
    long long l = -1, r = 1e12;
    while(l+1 < r){
        long long c = (l+r)/2;
        long long sum = 0;
        for(int i = 0; i < n; i++)sum += max(0ll, (a[i] - c/f[i]));
        if(sum <= k)r = c;
        else l = c;
    }
    cout << r << endl;
}