#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 2e5 + 7;
const int MAX = 1e9 + 1;
struct node {
  int a, b, c;
} x[N];
int n, k;
bool cmp(const node &l, const node &r) { return l.c < r.c; }
int main() {
  int i, j;
  cin >> n >> k;
  for (i = 0; i < n; ++i) {
    int t;
    cin >> t;
    x[i].a = t;
  }
  for (i = 0; i < n; ++i) {
    int t;
    cin >> t;
    x[i].b = t;
    x[i].c = x[i].a - t;
  }
  sort(x, x + n, cmp);
  i = 0;
  long long sum = 0;
  while (i < k || i < n && x[i].c < 0) {
    sum += (long long)x[i].a;
    ++i;
  }
  while (i < n) {
    sum += (long long)x[i].b;
    ++i;
  }
  cout << sum << endl;
  return 0;
}
