#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n;
  cin >> k;
  int a[n + 1], b[n + 1];
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  for (long long i = 1; i < n + 1; i++) {
    cin >> b[i];
    sum += b[i];
  }
  vector<pair<int, int>> discount;
  for (long long i = 1; i < n + 1; i++) {
    discount.push_back({-1 * (a[i] - b[i]), i});
  }
  sort((discount).begin(), (discount).end());
  int cnt = 0;
  long long discount_sum = 0;
  int ni;
  for (int i = n - 1; i >= 0; i--) {
    if (discount[i].first < 0) {
      ni = i;
      break;
    }
    discount_sum += discount[i].first;
    cnt++;
  }
  if (k <= cnt) {
    cout << sum - discount_sum << endl;
  } else {
    sum -= discount_sum;
    for (long long i = 0; i < k - cnt; i++) {
      sum -= discount[ni--].first;
    }
    cout << sum << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
