#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int b[N];
int c[N];
int main() {
  int n, k, sum = 0, cnt = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    c[i] = b[i] - a[i];
    if (c[i] > 0) cnt++;
  }
  sort(c, c + n);
  if (cnt > k) {
    for (int i = 0; i < n - cnt; i++) sum += c[i];
  } else {
    for (int i = 0; i < n - k; i++) sum += c[i];
  }
  cout << sum;
  return 0;
}
