#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
#define ll long long
#define N 200005
int n;
ll k;
ll a[N],f[N];
bool check(ll x)
{
	ll js=0;
	for(int i=1;i<=n;i++)
	{
		int xz=n-i+1;
		if(a[i]*f[xz]>x)
		{
			ll g=x/f[xz];
			js+=a[i]-g;
		}
	}
	return js<=k;
}
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&f[i]);
	sort(a+1,a+n+1);
	sort(f+1,f+n+1);
	ll l=0,r=a[n]*f[n];
	while(l<r)
	{
		//printf("%lld %lld\n",l,r);
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%lld",l);
}