#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main() {
  int n;
  ll k;
  cin>>n>>k;
  int a[n];
  int f[n];
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cin>>f[i];
  sort(a,a+n);
  sort(f,f+n);
  
  ll b=0;
  ll c=1e12+1;
  while(c-b>0){
    ll d=(b+c)/2;
    ll e[n];
    rep(i,0,n) e[i]=d/f[i];
    ll cur=0;
    rep(i,0,n){
      if(e[i]<a[n-1-i]) cur+=a[n-1-i]-e[i];
    }
    if(cur>k) b=d+1;
    else c=d;
  }
  cout<<b<<endl;
}

