#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
int n,he;
ll a[1000009],b[1000009];
ll ans=0;
bool check(ll sum,ll k)
{
  he=1;
  for (int i=n;i>=1;i--)
  {
    if (a[he]*b[i]<=sum) {he++;continue;}
    if ((a[he]-sum/b[i])>k) return false;
    k-=a[he]-sum/b[i];
    he++;
  }
  return true;
}
int main()
{
  ll k;
  scanf("%d%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+1+n); sort(b+1,b+1+n);
  ll l=0,r=0;
  r=b[n]*a[n];ans=r;
  while (l<=r)
  {
      ll mid=(l+r)/2;
      if (check(mid,k)) ans=mid,r=mid-1;
      else l=mid+1;
  }
  printf("%lld\n",ans);
  return 0;
}