#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+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBtc2V0KGFycix4KSBtZW1zZXQoYXJyLHgsc2l6ZW9mKGFycikpCiNkZWZpbmUgcmVwKGkscyxlKSBmb3IoaT1zO2k8PWU7aSsrKQojZGVmaW5lIHJyZXAoaSxzLGUpIGZvcihpPXM7aT49ZTtpLS0pCiNkZWZpbmUgbWluKGEsYikgKChhKTwoYik/KGEpOihiKSkKI2RlZmluZSBtYXgoYSxiKSAoKGEpPihiKT8oYSk6KGIpKQojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIGYgZmlyc3QKI2RlZmluZSBzIHNlY29uZAojZGVmaW5lIGFsbChjKSBjLmJlZ2luKCksYy5lbmQoKQogCnZlY3RvcjwgcGFpcjxsbCAsbGw+ID4gdmM7CmxsIGFyclsyMDAwMDEwXSwgYmFyclsyMDAwMDEwXTsKYm9vbCBjb21wKCBwYWlyPGxsICxsbD4gcGExLCBwYWlyPGxsICxsbD4gcGEyICkKewogICAgcmV0dXJuIChwYTEuZi1wYTEucyk8KHBhMi5mLXBhMi5zKTsKfQppbnQgbWFpbigpCnsKICAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgICBjaW4udGllKDApOwogCiAgICAgbGwgVCwgTiwgSywgaSwgaiwgYW5zID0gMDsKICAgICBzdHJpbmcgc3Q7CiAKICAgICBjaW4gPj4gTiA+PiBLOwogICAgIHJlcChpLCAxLCBOKQogICAgIHsKICAgICAgICAgY2luID4+IGFycltpXTsKICAgICB9CiAgICAgcmVwKGksIDEsIE4pCiAgICAgewogICAgICAgICBjaW4gPj4gYmFycltpXTsKICAgICAgICAgdmMucGIoIG1wKGFycltpXSwgYmFycltpXSkgKTsKICAgICB9CiAgICAgc29ydCggYWxsKHZjKSwgY29tcCApOwogICAgIHJlcChpLCAwLCBLLTEpCiAgICAgewogICAgICAgICBhbnMgKz0gdmNbaV0uZjsKICAgICB9CiAgICAgcmVwKGksIEssIE4tMSkKICAgICB7CiAgICAgICAgIGlmKCB2Y1tpXS5mPHZjW2ldLnMgKQogICAgICAgICB7CiAgICAgICAgICAgICBhbnMgKz0gdmNbaV0uZjsKICAgICAgICAgfQogICAgICAgICBlbHNlCiAgICAgICAgIHsKICAgICAgICAgICAgIGFucyArPSB2Y1tpXS5zOwogICAgICAgICB9CiAgICAgfQogICAgIGNvdXQgPDwgYW5zOwogCiAgICAgcmV0dXJuIDA7Cn0K