#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, k, a[N], b[N], sum, fday;
vector<pair<int, int> > myvec;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    if (a[i] <= b[i]) {
      sum += a[i];
      fday++;
    } else
      myvec.push_back({a[i] - b[i], i});
  }
  sort(myvec.begin(), myvec.end());
  for (int j = 0; j < myvec.size(); j++) {
    int i = myvec[j].second;
    if (fday < k) {
      sum += a[i];
      fday++;
    } else
      sum += b[i];
  }
  cout << sum << '\n';
  return 0;
}
