#include <bits/stdc++.h>
using namespace std;
struct diff {
  int differ;
  int ind;
};
bool cmp(diff a, diff b) { return a.differ > b.differ; }
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  vector<int> B(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < n; i++) cin >> B[i];
  vector<diff> arr(n);
  for (int i = 0; i < n; i++) {
    arr[i].differ = B[i] - A[i];
    arr[i].ind = i;
  }
  sort(arr.begin(), arr.end(), cmp);
  int i = 0;
  long long sum = 0;
  for (i = 0; i < k; i++) {
    int k = arr[i].ind;
    sum += A[k];
  }
  for (; i < n; i++) {
    if (arr[i].differ < 0) break;
    sum += A[arr[i].ind];
  }
  for (; i < n; i++) {
    int k = arr[i].ind;
    sum += B[k];
  }
  cout << sum;
}
