#include <bits/stdc++.h>
using namespace std;
void FastIO() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
}
int main() {
  FastIO();
  int n, k, sum = 0;
  cin >> n >> k;
  vector<int> a(n), b(n);
  vector<pair<int, int>> c(n);
  vector<bool> buy(n, true);
  for (int& x : a) cin >> x;
  for (int& x : b) cin >> x;
  for (int i = 0; i < n; ++i) c[i] = {a[i] - b[i], i};
  sort(c.begin(), c.end());
  int i;
  for (i = 0; i < k; ++i) sum += a[c[i].second], buy[c[i].second] = false;
  while (c[i].first <= 0 and i < n)
    sum += a[c[i].second], buy[c[i].second] = false, ++i;
  for (int j = 0; j < n; ++j)
    if (buy[j]) sum += b[j];
  cout << sum;
}
