#include <cstdio>
#include <algorithm>

typedef long long int64;

const int MAXN = 200000 + 10;

int n;
int64 m;
int a[MAXN], f[MAXN];

int main() {
	int i;
	int64 l, r, mid;
	int64 t;
	
	scanf("%d %lld", &n, &m);
	for(i=1; i<=n; i++) 
		scanf("%d", &a[i]);
	for(i=1; i<=n; i++)
		scanf("%d", &f[i]);
	
	std::sort(a+1, a+1+n);
	std::sort(f+1, f+1+n);
	std::reverse(f+1, f+1+n);
	l = 0;
	r = 1ll * a[n] * f[1];
	
	while(l ^ r){
		mid = (l+r)>>1;
		
		t = 0;
		for(i=1; i<=n and t<=m; i++)
			if(1ll * a[i] * f[i] > mid) 
				t += a[i] - mid / f[i];
		if(t<=m)
			r=mid;
		else
			l=mid+1;
	}
	printf("%lld\n", l);
	return 0;
}