#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct node {
  int num;
  int dif;
} c[N];
bool cmp(node a, node b) { return a.dif < b.dif; }
int main() {
  int n, k;
  int a[N], b[N];
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    c[i].dif = a[i] - b[i];
    c[i].num = i;
  }
  sort(c + 1, c + 1 + n, cmp);
  long long sum = 0;
  for (int i = 1; i <= k; i++) {
    sum += a[c[i].num];
    b[c[i].num] = -1;
  }
  k++;
  while (c[k].dif < 0) {
    sum += a[c[k].num];
    b[c[k].num] = -1;
    k++;
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] != -1) sum += b[i];
  }
  printf("%lld\n", sum);
}
