#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long ans = 0;
map<long long, int> mp;
vector<pair<long long, long long> > v;
vector<pair<long long, long long> > u;
priority_queue<pair<long long, long long> > pq;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  long long x;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    v.push_back(make_pair(x, i));
  }
  for (long long i = 0; i < n; i++) {
    cin >> x;
    u.push_back(make_pair(x, i));
    pq.push(make_pair((u[i].first - v[i].first), i));
  }
  for (long long i = 0; i < k; i++) {
    long long index = pq.top().second;
    mp[index] = 1;
    ans += v[index].first;
    pq.pop();
  }
  while (pq.top().first > 0 && (!pq.empty())) {
    long long index = pq.top().second;
    mp[index] = 1;
    ans += v[index].first;
    pq.pop();
  }
  for (long long i = 0; i < u.size(); i++) {
    if (mp[i] == 0) {
      ans += u[i].first;
    }
  }
  cout << ans;
  return 0;
}
