#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=200010;
ll n,k,a[MAXN],b[MAXN];
bool cmp (ll a,ll b) {return a>b;}
bool chk (ll x) {
	ll res=0;
	for (int i=1;i<=n;i++) {res+=max(0ll,a[i]-x/b[i]);}
	return (res<=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",&b[i]);}
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+n+1);
	ll l=0,r=1e12;
	while (l<r) {
		ll mid=(l+r)>>1;
		if (chk(mid)) {r=mid;}
		else {l=mid+1;}
	}
	printf("%lld\n",l);
	return 0;
}