#include <bits/stdc++.h>
using namespace std;
int inpt1[300000], inpt2[300000];
int main() {
  priority_queue<int> q;
  int n, k, x, sm;
  scanf("%d %d", &n, &k);
  sm = 0;
  for (int i = 0; i < n; i++) scanf("%d", &inpt1[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    sm += x;
    inpt2[i] = x - inpt1[i];
    q.push(inpt2[i]);
  }
  while (!q.empty()) {
    x = q.top();
    if (x < 0) break;
    q.pop();
    sm -= x;
    --k;
  }
  while (k > 0) {
    k--;
    x = q.top();
    q.pop();
    sm -= x;
  }
  cout << sm << endl;
  return 0;
}
