#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(arr,x) memset(arr,x,sizeof(arr))
#define rep(i,s,e) for(i=s;i<=e;i++)
#define rrep(i,s,e) for(i=s;i>=e;i--)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(c) c.begin(),c.end()
vector< pair<ll ,ll> > vc;
ll arr[2000010], barr[2000010];
bool comp( pair<ll ,ll> pa1, pair<ll ,ll> pa2 )
{
return (pa1.f-pa1.s)<=(pa2.f-pa2.s);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll T, N, K, i, j, ans = 0;
string st;
cin >> N >> K;
rep(i, 1, N)
{
cin >> arr[i];
}
rep(i, 1, N)
{
cin >> barr[i];
vc.pb( mp(arr[i], barr[i]) );
}
sort( all(vc), comp );
rep(i, 0, K-1)
{
ans += vc[i].f;
}
rep(i, K, N-1)
{
if( vc[i].f<vc[i].s )
{
ans += vc[i].f;
}
else
{
ans += vc[i].s;
}
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIG1zZXQoYXJyLHgpIG1lbXNldChhcnIseCxzaXplb2YoYXJyKSkKI2RlZmluZSByZXAoaSxzLGUpIGZvcihpPXM7aTw9ZTtpKyspCiNkZWZpbmUgcnJlcChpLHMsZSkgZm9yKGk9cztpPj1lO2ktLSkKI2RlZmluZSBtaW4oYSxiKSAoKGEpPChiKT8oYSk6KGIpKQojZGVmaW5lIG1heChhLGIpICgoYSk+KGIpPyhhKTooYikpCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgZiBmaXJzdAojZGVmaW5lIHMgc2Vjb25kCiNkZWZpbmUgYWxsKGMpIGMuYmVnaW4oKSxjLmVuZCgpCgp2ZWN0b3I8IHBhaXI8bGwgLGxsPiA+IHZjOwpsbCBhcnJbMjAwMDAxMF0sIGJhcnJbMjAwMDAxMF07CmJvb2wgY29tcCggcGFpcjxsbCAsbGw+IHBhMSwgcGFpcjxsbCAsbGw+IHBhMiApCnsKICAgIHJldHVybiAocGExLmYtcGExLnMpPD0ocGEyLmYtcGEyLnMpOwp9CmludCBtYWluKCkKewogICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgIGNpbi50aWUoMCk7CgogICAgIGxsIFQsIE4sIEssIGksIGosIGFucyA9IDA7CiAgICAgc3RyaW5nIHN0OwoKICAgICBjaW4gPj4gTiA+PiBLOwogICAgIHJlcChpLCAxLCBOKQogICAgIHsKICAgICAgICAgY2luID4+IGFycltpXTsKICAgICB9CiAgICAgcmVwKGksIDEsIE4pCiAgICAgewogICAgICAgICBjaW4gPj4gYmFycltpXTsKICAgICAgICAgdmMucGIoIG1wKGFycltpXSwgYmFycltpXSkgKTsKICAgICB9CiAgICAgc29ydCggYWxsKHZjKSwgY29tcCApOwogICAgIHJlcChpLCAwLCBLLTEpCiAgICAgewogICAgICAgICBhbnMgKz0gdmNbaV0uZjsKICAgICB9CiAgICAgcmVwKGksIEssIE4tMSkKICAgICB7CiAgICAgICAgIGlmKCB2Y1tpXS5mPHZjW2ldLnMgKQogICAgICAgICB7CiAgICAgICAgICAgICBhbnMgKz0gdmNbaV0uZjsKICAgICAgICAgfQogICAgICAgICBlbHNlCiAgICAgICAgIHsKICAgICAgICAgICAgIGFucyArPSB2Y1tpXS5zOwogICAgICAgICB9CiAgICAgfQogICAgIGNvdXQgPDwgYW5zOwoKICAgICByZXR1cm4gMDsKfQ==