#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007;


int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N),F(N);
  rep(i,N){
      cin>>A[i];
  }
  rep(i,N){
      cin>>F[i];
  }
  sort(A.begin(),A.end());
  sort(F.begin(),F.end());
  reverse(F.begin(),F.end());
  ll l=-1,r=A.at(N-1)*F.at(0);
  while(r-l>1){
      ll m=(r+l)/2;
      ll count=0;
      rep(i,N){
          if(F.at(i)*A.at(i)>m){
              count+=A.at(i)-m/F.at(i);
          }
      }
      if(count<=K){r=m;}
      else{l=m;}
  }
  cout<<r<<endl;
}