#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int N, K;
	cin >> N >> K;
	vector<Int> 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.rbegin(), A.rend());
	sort(F.begin(), F.end());

	Int low = -1, high = 1e18;
	while (high - low > 1) {
		Int mid = (high + low) / 2;

		Int sum = 0;
		for (int i = 0; i < N; ++i) {
			sum += max(Int(0), A[i] - (mid / F[i]));
		}
		if (sum > K) { low = mid; }
		else { high = mid; }
	}
	cout << high << endl;

	return 0;
}
