#include <bits/stdc++.h>
using namespace std;
int n, k;
bool taken[100009];
int main() {
  cin >> n >> k;
  vector<long long> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    ans += b[i];
    c[i] = a[i] - b[i];
  }
  sort(c.begin(), c.end());
  for (int i = 0; i < n; i++) {
    if (i < k || c[i] < 0)
      ans += c[i];
    else
      break;
  }
  cout << ans << endl;
  return 0;
}
