#include <bits/stdc++.h>
#define pi 3.14159265359
using namespace std;
int main() {
int N;
long long M;
cin >> N >> M;
if(M == 0) {cout << "0\n"; return 0;}
vector<long long> A(N),B(N);
for(int i =0; i < N; i++) cin >> A[i];
for(int i =0; i < N; i++) cin >> B[i];
long long Cmin =0,Cmax =1000000000+42;
while(Cmax-Cmin > 1) {
long long C =(Cmin+Cmax)/2, m =0;
for(int i =0; i < N; i++) if(A[i] >= C) {
long long k =(A[i]-C)/B[i]+1;
m +=k;}
if(m < M) Cmax =C;
else Cmin =C;}
long long ans =0, m =0;
for(int i =0; i < N; i++) if(A[i] >= Cmax) {
long long k =(A[i]-Cmax)/B[i]+1;
m +=k;
ans +=1LL*k*A[i]-B[i]*1LL*k*(k-1)/2;}
ans +=(M-m)*max(1LL,Cmin);
cout << ans << "\n";
return 0;}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGkgMy4xNDE1OTI2NTM1OQp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgTjsKCWxvbmcgbG9uZyBNOwoJY2luID4+IE4gPj4gTTsKCWlmKE0gPT0gMCkge2NvdXQgPDwgIjBcbiI7IHJldHVybiAwO30KCXZlY3Rvcjxsb25nIGxvbmc+IEEoTiksQihOKTsKCWZvcihpbnQgaSA9MDsgaSA8IE47IGkrKykgY2luID4+IEFbaV07Cglmb3IoaW50IGkgPTA7IGkgPCBOOyBpKyspIGNpbiA+PiBCW2ldOwoJbG9uZyBsb25nIENtaW4gPTAsQ21heCA9MTAwMDAwMDAwMCs0MjsKCXdoaWxlKENtYXgtQ21pbiA+IDEpIHsKCQlsb25nIGxvbmcgQyA9KENtaW4rQ21heCkvMiwgbSA9MDsKCQlmb3IoaW50IGkgPTA7IGkgPCBOOyBpKyspIGlmKEFbaV0gPj0gQykgewoJCQlsb25nIGxvbmcgayA9KEFbaV0tQykvQltpXSsxOwoJCQltICs9azt9CgkJaWYobSA8IE0pIENtYXggPU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