#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, greater<int> > Q;
int a[200007], b[200007];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int sum = 0;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &b[i]), sum += max(a[i], b[i]), Q.push(a[i] - b[i]);
  while (!Q.empty() && (k > 0 || Q.top() < 0)) {
    int t = Q.top();
    Q.pop();
    if (t < 0) sum += t;
    --k;
  }
  while (!Q.empty()) {
    int t = Q.top();
    Q.pop();
    t = -t;
    sum += t;
  }
  printf("%d", sum);
}
