#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long MAX = 1e17;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  int n, k;
  long long sum = 0;
  cin >> n >> k;
  int a[n], b[n], z = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  vector<int> d;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i] < a[i]) {
      z++;
      d.push_back(b[i] - a[i]);
    }
  }
  d.resize(z);
  sort(d.begin(), d.end());
  if (z <= n - k) {
    for (int i = 0; i < z; i++) sum += d[i];
  } else {
    for (int i = 0; i < n - k; i++) sum += d[i];
  }
  cout << sum << endl;
}
