#include <bits/stdc++.h>
using namespace std;
struct ab {
  int a;
  int b;
};
bool cmp(const ab& x, const ab& y) { return x.a - x.b < y.a - y.b; }
ab AB[200000];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> AB[i].a;
  for (int i = 0; i < n; ++i) cin >> AB[i].b;
  sort(AB, AB + n, cmp);
  int val = 0;
  for (int i = 0; i < k; i++) val += AB[i].a;
  for (int i = k; i < n; i++) val += AB[i].b <= AB[i].a ? AB[i].b : AB[i].a;
  cout << val << endl;
  return 0;
}
