#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000, MAXINT = ((1 << 30) - 1) * 2 + 1;
int n, K, ans, suma[maxn + 5], sumb[maxn + 5];
struct Thing {
  int a, b;
  bool operator<(const Thing &c) const { return a - b < c.a - c.b; }
};
Thing p[maxn + 5];
bool Eoln(char ch) { return ch == 10 || ch == 13 || ch == EOF; }
int readi(int &x) {
  int tot = 0, f = 1;
  char ch = getchar();
  if (ch == EOF) return EOF;
  while ('9' < ch || ch < '0') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') tot = tot * 10 + ch - 48, ch = getchar();
  x = tot * f;
  return Eoln(ch);
}
int main() {
  readi(n);
  readi(K);
  for (int i = 1; i <= n; i++) readi(p[i].a);
  for (int i = 1; i <= n; i++) readi(p[i].b);
  sort(p + 1, p + 1 + n);
  for (int i = 1; i <= n; i++) suma[i] = suma[i - 1] + p[i].a;
  for (int i = 1; i <= n; i++) sumb[i] = sumb[i - 1] + p[i].b;
  ans = MAXINT;
  for (int i = K; i <= n; i++) ans = min(ans, suma[i] + sumb[n] - sumb[i]);
  printf("%d\n", ans);
  return 0;
}
