#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch;
  int x = 0;
  bool f = 0;
  while (ch = getchar(), ch < '!')
    ;
  if (ch == '-') f = 1, ch = getchar();
  while (x = x * 10 + ch - '0', ch = getchar(), isdigit(ch))
    ;
  return f ? -x : x;
}
const int N = 200005;
int n, k;
long long a[N], b[N], c[N];
int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read(), c[i] = a[i] - b[i];
  sort(c + 1, c + n + 1);
  long long ans = 0;
  int i;
  for (i = 1; i <= k; i++) ans += c[i];
  for (; i <= n && c[i] < 0; i++) ans += c[i];
  for (i = 1; i <= n; i++) ans += b[i];
  return !printf("%I64d\n", ans);
}
