#include <bits/stdc++.h>
using namespace std;
const int mxn = 200010;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 - '0' + ch;
    ch = getchar();
  }
  return x * f;
}
struct node {
  int a, b, c;
} t[mxn];
int cmp(node x, node y) { return x.c < y.c; }
int n, k;
int main() {
  int i, j;
  n = read();
  k = read();
  for (i = 1; i <= n; i++) {
    t[i].a = read();
  }
  for (i = 1; i <= n; i++) {
    t[i].b = read();
    t[i].c = t[i].a - t[i].b;
  }
  sort(t + 1, t + n + 1, cmp);
  int ans = 0;
  for (i = 1; i <= k; i++) {
    ans += t[i].a;
  }
  for (i = k + 1; i <= n; i++) {
    ans += min(t[i].a, t[i].b);
  }
  printf("%d\n", ans);
  return 0;
}
