#include <bits/stdc++.h>
using namespace std;
struct gogu {
  int val, ief, dif;
} v[200010];
int i, j, n, m, k, t, p, r;
bool compv(gogu a, gogu b) { return a.dif < b.dif; }
long long sum = 0;
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> v[i].val;
  }
  for (i = 1; i <= n; i++) {
    cin >> v[i].ief;
    v[i].dif = v[i].val - v[i].ief;
  }
  sort(v + 1, v + n + 1, compv);
  for (i = 1; i <= n; i++) {
    if (i <= k || v[i].dif < 0)
      sum += v[i].val;
    else
      sum += v[i].ief;
  }
  cout << sum;
}
