#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long x[n + 5];
  long long y[n + 5];
  vector<long long> z;
  vector<pair<long long, long long>> w;
  for (long long i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> y[i];
  }
  for (long long i = 0; i < n; i++) {
    w.push_back(make_pair(x[i] - y[i], i));
  }
  sort(w.begin(), w.end());
  long long sum1 = 0;
  int k = 0;
  for (long long i = 0; i < n; i++) {
    if (x[i] <= y[i]) {
      k++;
      sum1 += x[i];
    } else {
      sum1 += y[i];
    }
  }
  if (k >= m) {
    cout << sum1 << endl;
  } else {
    long long sum = 0;
    for (long long i = 0; i < m; i++) {
      sum += x[w[i].second];
      y[w[i].second] = 0;
    }
    for (long long i = 0; i < n; i++) {
      sum += y[i];
    }
    cout << sum << endl;
  }
  return 0;
}
