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

const int maxn=2e5+6;
int a[maxn],f[maxn],n;
long long t,ans;

bool cmp(int a,int b) {return a>b;}

bool check(long long x)
{
	long long cnt=0;
	for(int i=1;i<=n;++i) {
		cnt+=max(a[i]-x/f[i],0ll);
	}
	return cnt<=t;
}

int main()
{
	scanf("%d %lld",&n,&t);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	for(int i=1;i<=n;++i) scanf("%d",f+i);
	sort(f+1,f+n+1,cmp);
	sort(a+1,a+n+1);
	long long l=0,r=1e12;
	while(l<r) {
		long long mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld",l);
}