#include <bits/stdc++.h>
using namespace std;
typedef struct Price {
  int x;
  int y;
  bool operator<(const Price &b) const {
    if (x - y < b.x - b.y) return 1;
    return 0;
  }
} Price;
Price s[200005];
int main(void) {
  int n, k, i;
  long long ans = 0;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &s[i].x);
  for (i = 1; i <= n; i++) scanf("%d", &s[i].y);
  sort(s + 1, s + n + 1);
  for (i = 1; i <= k; i++) ans += s[i].x;
  while (s[i].x < s[i].y && i <= n) ans += s[i++].x;
  while (i <= n) ans += s[i++].y;
  printf("%I64d\n", ans);
  return 0;
}
