#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long n, k, ans = 0;
  cin >> n >> k;
  long long a[n], b[n];
  long long c[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    ans += a[i];
  }
  for (long long i = 0; i < n; ++i) {
    cin >> b[i];
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);
  for (int i = n - 1; i >= k and c[i] > 0; i--) ans -= c[i];
  cout << ans;
  return 0;
}
