#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  vector<pair<int, int> > c;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    c.push_back(make_pair(a[i] - b[i], i));
  }
  sort(c.begin(), c.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[c[i].second];
  }
  for (int i = k; i < c.size(); i++) {
    ans += min(a[c[i].second], b[c[i].second]);
  }
  cout << ans << endl;
  return 0;
}
