#include <bits/stdc++.h>
using namespace std;
struct Pair {
  int a, b, c;
};
int a1[200009], a2[200009];
vector<Pair> arr;
bool rules(Pair x, Pair y) { return ((x.a - x.b) < (y.a - y.b)); }
int main() {
  int n, k, sum = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a1[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a2[i]);
    Pair p;
    p.a = a1[i], p.b = a2[i];
    arr.push_back(p);
  }
  sort(arr.begin(), arr.end(), rules);
  for (int i = 0; i < k; i++) sum += arr[i].a;
  for (int i = k; i < n; i++) sum += min(arr[i].a, arr[i].b);
  printf("%d\n", sum);
  return 0;
}
