#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int n, k;
  cin >> n >> k;
  int ar[n], br[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = 0; i < n; i++) cin >> br[i];
  for (int i = 0; i < n; i++) v.push_back(make_pair(ar[i], ar[i] - br[i]));
  sort(v.begin(), v.end(), sortbysec);
  long long int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += v[i].first;
  }
  for (int j = k; j < n; j++) {
    if (v[j].second < 0)
      sum += v[j].first;
    else
      sum += v[j].first - v[j].second;
  }
  cout << sum << endl;
  return 0;
}
