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

typedef long long ll;

ll N, K, a[200002], f[200002];

bool fun(ll m){
	ll cnt = 0;
	for(int i = 1; i<=N; i++){
		ll rt = m/f[i];
		if(rt < a[i]) cnt += a[i]-rt;
	}
	return cnt <= K;
}

int main(){
	scanf("%lld %lld", &N, &K);


	for(int i = 1; i <= N; i++){scanf("%lld", &a[i]);}
	for(int i = 1; i <= N; i++){scanf("%lld", &f[i]);}
	sort(a+1, a+N+1); sort(f+1, f+N+1, greater<ll>());

	ll lo = 0, hi = 1e12;
	while(lo<=hi){
		ll mid = (lo+hi)/2;
		if(fun(mid)) hi = mid-1;
		else lo = mid+1;
	}
	printf("%lld\n", lo);
	return 0;
}