#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;
const double PI = 3.1415926535;


//E
struct LLPair {
	ll a = 0;
	ll f = 0;
	ll time() {
		return a * f;
	}
};

int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	vector<ll> A(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	vector<ll> F(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &F[i]);
	}

	std::sort(A.begin(), A.end(), std::greater<ll>());
	std::sort(F.begin(), F.end());

	ll time_under = 0;
	ll time_upper = 1000000000000;

	while (time_under != time_upper) {
		ll judge_time = (time_upper + time_under) / 2;

		ll needKsum = 0;
		for (ll i = 0; i < N; i++) {
			ll maxA = judge_time / F[i];
			ll needTrain = A[i] - maxA;

			if (needTrain > 0) {
				needKsum += needTrain;
			}
		}

		if (needKsum <= K) {
			//ok
			time_upper = judge_time;
		}
		else {
			//ng
			time_under = judge_time + 1;
		}
	}

	printf("%lld\n", time_upper);
}

/*
struct LLPair {
	ll a = 0;
	ll aMax = 0;
	ll f = 0;
	ll time() {
		return a * f;
	}
};

bool operator< (const LLPair &p1, const LLPair &p2) {
	return (p1.a + 1) * p1.f > (p2.a + 1) * p2.f;
};

int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	vector<ll> A(N);
	ll sumA = 0;
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		sumA += A[i];
	}
	vector<ll> F(N);
	ll sumF = 0;
	double sumFinv = 0.0;
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &F[i]);
		sumF += F[i];
		sumFinv += 1.0 / (double)F[i];
	}

	std::sort(A.begin(), A.end(), std::greater<ll>());
	std::sort(F.begin(), F.end());

	ll lastA = sumA - K;
	if (lastA <= 0) {
		printf("0\n");
		return 0;
	}

	ll result = 0;
	priority_queue<LLPair> pq;

	for (ll i = 0; i < N; i++) {
		LLPair p;

		p.aMax = A[i];
		p.f = F[i];

		ll a0 = min((ll)((double)lastA * (1.0 / (double)F[i]) / sumFinv), A[i]);
		p.a = a0;
		lastA -= a0;

		result = max(result, p.time());

		pq.push(p);
	}


	while (lastA > 0) {
		LLPair first = pq.top();
		pq.pop();

		first.a++;
		ll time = first.time();

		result = max(time, result);

		if (first.a < first.aMax) {
			pq.push(first);
		}

		lastA--;
	}

	printf("%lld\n", result);
}
*/

/*
struct LLPair {
	ll a = 0;
	ll f = 0;
	ll time() {
		return a * f;
	}
};

bool operator< (const LLPair &p1, const LLPair &p2) {
	return p1.a * p1.f < p2.a * p2.f;
};

int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	vector<ll> A(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	vector<ll> F(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &F[i]);
	}

	std::sort(A.begin(), A.end(), std::greater<ll>());
	std::sort(F.begin(), F.end());

	priority_queue<LLPair> pq;
	for (ll i = 0; i < N; i++) {
		LLPair p;
		p.a = A[i];
		p.f = F[i];

		pq.push(p);
	}

	ll i = 0;
	while (i < K) {
		LLPair first = pq.top();
		if (first.time() == 0) {
			break;
		}
		pq.pop();

		LLPair second = pq.top();
		
		ll sub = first.time() - second.time();
		ll train_max = sub / first.f + 1;
		ll train = min(K - i, train_max);
		if (train > first.a) {
			train = first.a;
		}

		first.a -= train;
		i += train;

		pq.push(first);
	}

	LLPair top = pq.top();
	ll result = top.time();

	printf("%lld\n", result);
}
*/

//D
/*
int main() {
	ll a;
	scanf("%lld", &a);
	ll b;
	scanf("%lld", &b);
	ll x;
	scanf("%lld", &x);

	ll area = a * a;
	ll allCap = a * a * b;

	double theta = 0.0;

	if (x * 2ll >= allCap) {
		double c = 2.0 / (double)area * ((double)area * (double)b - (double)x);
		theta = atan2(c, a);
	}
	else {
		double c = 2.0 * (double)x / (double)a / (double)b;
		theta = atan2(b, c);
	}


	double result = 0;

	result = theta * 180.0 / PI;

	printf("%0.10f\n", result);
}
*/

//C
/*
int main() {
	ll N;
	scanf("%lld", &N);

	ll result = INF;

	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll move = (i - 1) + (N / i - 1);
			result = min(result, move);
		}
	}

	printf("%lld\n", result);
}
*/

//B
/*
int main() {
	ll N;
	scanf("%lld", &N);

	bool result = false;

	for (ll i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i <= 9) {
			result = true;
			break;
		}
	}

	if (result == true) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}
*/

//A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	if (A <= 9 && B <= 9) {
		result = A * B;
	}
	else {
		result = -1;
	}

	printf("%lld\n", result);
}
*/


Measured memory_bytes: 3328