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

ll N, K, A[200010], F[200010];

ll search(void){
	ll ok = 1e13, ng = -1;
	while(ok - ng > 1){
		ll cnt = 0;
		ll mid = (ok + ng)/2;
		for(int i=0; i<N; i++){
			if(mid < F[i]*A[N-1-i]){
				cnt += A[N-1-i] - mid/F[i];
			}
		}
		if(cnt <= K){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	return ok;
}

int main(){
	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);
	cout << search() << endl;
	return 0;
}
