#include <bits/stdc++.h>
using namespace std;
long long kk, nn;
long long n, k;
struct node {
  long long a, b, dif;
} arr[200005];
bool cmp(node n1, node n2) {
  if (n1.dif == n2.dif)
    return n1.a < n2.a;
  else
    return n1.dif < n2.dif;
}
int main() {
  cin >> n >> k;
  for (long long i = 0; i < n; i++) scanf("%lld", &arr[i].a);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &arr[i].b);
    arr[i].dif = arr[i].a - arr[i].b;
  }
  sort(arr, arr + n, cmp);
  long long take = 0;
  long long sum = 0;
  for (long long i = 0; i < k; i++) sum += arr[i].a;
  for (long long i = k; i < n; i++) sum += min(arr[i].a, arr[i].b);
  cout << sum << endl;
  return 0;
}
