#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+5;
int a[N], b[N];
bool can(long long mn, int n, int m){
long long have = 1ll*n*m;
long long need = 0;
for(int i = 1; i<= n; i++){
long long weeks = (mn+a[i]-1)/a[i];
if(weeks > m){
long long temp = mn;
temp -= m*a[i];
weeks = m + (temp+b[i]-1)/b[i];
}
need += weeks;
if(need>have)
return 0;
}
return (have>=need);
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, m; cin >> n >> m;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 1; i <= n; i++){
cin >> b[i];
a[i] = max(a[i],b[i]);
}
/*
if(m==1){
int ans = 1e9+1;
for(int i = 0; i < n; i++){
ans = min(ans,max(a[i],b[i]));
}
cout << ans;
return 0;
}*/
long long l = 1; long long r = 1e18+1;
while(l+1<r){
long long mid = (l+r)/2;
if(can(mid,n,m))
l = mid;
else
r = mid;
}
if(can(r,n,m))
cout << r;
else
cout << l;
return 0;
}