#include <bits/stdc++.h>
using namespace std;
struct str {
  int a;
  int b;
  int c;
} s[200005];
bool cmp(str s1, str s2) {
  if (s1.c < s2.c)
    return true;
  else
    return false;
}
int main() {
  int n, k, i;
  while (cin >> n) {
    int sum = 0;
    cin >> k;
    for (i = 0; i < n; i++) cin >> s[i].a;
    for (i = 0; i < n; i++) {
      cin >> s[i].b;
      s[i].c = s[i].a - s[i].b;
    }
    sort(s, s + n, cmp);
    for (i = 0; i < n; i++) {
      if (s[i].c <= 0)
        sum += s[i].a;
      else if (i < k)
        sum += s[i].a;
      else
        sum += s[i].b;
    }
    cout << sum << endl;
  }
  return 0;
}
