#include <bits/stdc++.h>
using namespace std;
#define int long long
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100005
#define INF 0x7fffffff
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define mat(x, y, name) vector< vector<int> > name (x, vector<int>(y));
#define printMat(name) for (int i = 0; i < name.size(); ++i) {for (int j = 0; j < res[i].size(); ++j) cout << res[i][j] << " "; cout << endl;}
#define printArr(name) for (int i : name) cout << i << " "; cout << '\n'
const int M = 1e9 + 7;
const double const_PI = 3.1415926, const_e = 2.7182818;
int powMod(int a, int b, int m) { int x = 1; while (b > 0) { if (b&1) x = (x*a) % m; a = (a*a) % m; b >>= 1;} return x; }
int nCr(int n, int r, int m) { if (n < r) return 0; int res = 1, rem = 1; for (int i = n - r + 1; i <= n; i++) res = (res * i) % m; for (int i = 2; i <= r; i++) rem = (rem * i) % m; return (res * powMod(rem, m - 2, m)) % m; }
int modInverse(int a, int m) { a = a % m; for (int x = 1; x < m; ++x) { if ((a * x) % m == 1) return x; } return -1; }
int gcdExtended(int a, int b, int *x, int *y) { if (b == 0) { *x = 1, *y = 0; return a; } int x1, y1; int gcd = gcdExtended(b, a%b, &x1, &y1); *x = y1, *y = x1 - (floor(a/b) * y1); return gcd; }
int factorial(int n) { if (n == 1) return 1; return sqrt(2 * const_PI * n) * pow((n / const_e), n); }
vector<bool> sieve(int n) { int sqrtn = sqrt(n); vector<bool> is_prime(n+1, true); for (int i = 3; i <= sqrtn; i += 2) { if (is_prime[i]) { int increment = i+i; for (int j = i * i; j <= n; j += increment) is_prime[j] = false; } } return is_prime; }
vector< vector<int> > matMul(vector< vector<int> > A, vector< vector<int> > B) { vector< vector<int> > C(A.size(), vector<int>(B[0].size())); for (int i = 0; i < A.size(); ++i) { for (int j = 0; j < B[0].size(); ++j) { C[i][j] = 0; for (int k = 0; k < B.size(); ++k) C[i][j] = (C[i][j] + ((A[i][k] * B[k][j]) % M)) % M; } } return C; }
vector< vector<int> > matPow(vector< vector<int> > A, int p) { if (p == 1) return A; if (p&1) return matMul(A, matPow(A, p-1)); else { vector< vector<int> > C = matPow(A, p/2); return matMul(C, C); } }
vector<int> zFunction(string s) { int n = s.size(), L = 0, R = 0; vector<int> z(n); for (int i = 1; i < n; ++i) { if (i > R) { L = R = i; while (R < n && s[R - L] == s[R]) R++; z[i] = R - L; R--; } else { int k = i - L; if (z[k] < R - i + 1) z[i] = z[k]; else { L = i; while (R < n && s[R - L] == s[R]) R++; z[i] = R - L; R--; } } } return z; }
vector<int> patterMatch(string text, string pattern) { string key = pattern + '$' + text; vector<int> z = zFunction(key); vector<int> res; int m = pattern.size(); for (int i = m+1; i < key.size(); ++i) if (z[i] == m) res.push_back(i-m-1); return res; }
int fact[MAXN], inv[MAXN];
void nCr_preProcess() { fact[0] = inv[0] = 1; for(int i = 1; i < MAXN; ++i) { fact[i] = (fact[i-1] * i) % M; inv[i] = powMod(fact[i], M-2, M); } }
int nCr_query(int n, int r, int M) { int res = 1; res = (res * 1ll * fact[n]) % M; res = (res * 1ll * inv[r]) % M; res = (res * 1ll * inv[n-r]) % M; return res; }

signed main()
{
    flash;
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end());
    int l = 0, r = a[0] * b.back();
    while (l < r)
    {
        int mid = l + (r - l)/2;
        int reqd = 0;
        for (int i = 0; i < n; ++i) reqd += max(0LL, a[i] - (mid / b[i]));
        if (reqd <= k) r = mid;
        else l = mid+1;
    }
    cout << l << '\n';
    return 0;
}


Measured memory_bytes: 3328