#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 1;
const int inf = 0x3f3f3f3f;
struct node {
  int a, b, c;
} w[maxn];
bool cmp(node a, node b) { return a.c > b.c; }
int main() {
  int n, k;
  int sum = 0;
  int ans = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &w[i].a);
  for (int i = 0; i < n; i++) scanf("%d", &w[i].b);
  for (int i = 0; i < n; i++) w[i].c = w[i].b - w[i].a;
  sort(w, w + n, cmp);
  for (int i = 0; i < n; i++) {
    if (w[i].c > 0) {
      sum += w[i].a;
      w[i].a = w[i].b = w[i].c = -inf;
      ans++;
    }
  }
  sort(w, w + n, cmp);
  if (ans < k) {
    for (int i = 0; i < k - ans; i++) {
      sum += w[i].a;
      w[i].a = w[i].b = -inf;
    }
  }
  for (int i = 0; i < n; i++) {
    if (w[i].a != -inf) sum += w[i].b;
  }
  printf("%d\n", sum);
  return 0;
}
