#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using ll = long long;
using vb = vector<bool>;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vi a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  vii arr(n);
  for (int i = 0; i < n; i++) arr[i] = make_pair(a[i] - b[i], i);
  sort(arr.begin(), arr.end());
  vb h(n, true);
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[arr[i].second];
    h[arr[i].second] = false;
  }
  for (int i = k; i < n; i++) {
    if (arr[i].first < 0) {
      h[arr[i].second] = false;
      ans += a[arr[i].second];
    }
  }
  for (int i = 0; i < n; i++) {
    if (h[i]) {
      ans += b[i];
    }
  }
  cout << ans << '\n';
  return 0;
}
