#include "bits/stdc++.h"
using namespace std;

int main() {
	static long long N, K, A[200000], F[200000], L = -1, R = 100000000000000000;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> F[i];
	sort(A, A + N);
	sort(F, F + N, greater<long long>());
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		long long COUNT = 0;
		for (int i = 0; i < N; i++) {
			COUNT += max(0LL, A[i] - MID / F[i]);
		}
		if (COUNT <= K) R = MID;
		else L = MID;
	}
	cout << R << endl;
}