#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N), 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());
	sort(F.rbegin(), F.rend());
	ll lb = -1, ub = 1e13;
	while (ub - lb > 1) {
		ll m = (lb + ub) / 2;
		ll co = 0;
		for (int i = 0; i < N; i++) {
			co += max(0LL, A[i] - m / F[i]);
		}
		(co <= K ? ub : lb) = m;
	}
	cout << ub << endl;
	return 0;
}
