#include <bits/stdc++.h>
using namespace std;
#define ll long long
using i128 = __int128_t;
const ll MOD = 1e9 + 7;
ll AllNegative=1;
ll SubtaskIV=1;
ll n,m;
using i128 = __int128_t;
bool check(ll x, vector<ll>& BLst, ll limit){
i128 total = 0;
i128 lim = (i128)limit;
for(ll i = 0; i < n; i++){
total += ((i128)x + BLst[i] - 1) / BLst[i];
if(total > lim) return false;
}
return total <= lim;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
vector<ll> Alst(n);
vector<ll> Blst(n);
for(ll i=0;i<n;i++){
cin >> Alst[i];
}
for(ll i=0;i<n;i++){
cin >> Blst[i];
if(Blst[i]!=Alst[i]){
SubtaskIV=0;
}
}
if(SubtaskIV==1){
ll L=1;
ll R=1e18;
ll ans;
while(L<=R){
ll mid=L+(R-L)/2;
if(check(mid, Blst, n*m)){
ans=mid;
L=mid+1;
}
else{
R=mid-1;
}
}
cout << ans;
return 0;
}
vector<ll> Comprehension(n,0);
for(ll i=0;i<n;i++){
Comprehension[i]+=max(Alst[i],Blst[i]);
}
ll ans=LLONG_MAX;
for(ll i:Comprehension){
ans=min(ans,i);
}
priority_queue<pair<ll,ll>, vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
for(ll i=0;i<n;i++){
pq.push({Comprehension[i],i});
}
for(ll i=1;i<m;i++){
for(ll j=0;j<n;j++){
pair<ll,ll> Curr=pq.top();
pq.pop();
ll CurrAmount=Curr.first;
ll CurrPos=Curr.second;
if(j==CurrPos){
CurrAmount+=max(Alst[CurrPos],Blst[CurrPos]);
}
else{
CurrAmount+=Blst[CurrPos];
}
pq.push({CurrAmount,CurrPos});
}
}
cout << (pq.top()).first;
}