#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  vector<int> v1, v2;
  cin >> n >> k;
  v1.assign(n, 0);
  v2.assign(n, 0);
  for (int i = 0; i < n; i++) cin >> v1[i];
  for (int i = 0; i < n; i++) cin >> v2[i];
  vector<pii> v;
  for (int i = 0; i < n; i++) v.push_back({v1[i], v2[i]});
  sort(v.begin(), v.end(), [](pii &p1, pii &p2) {
    return (p1.first - p1.second) < (p2.first - p2.second);
  });
  int ans(0), taken(0);
  for (int i = 0; i < n; i++) {
    if (taken < k || v[i].first - v[i].second < 0) {
      ++taken;
      ans += v[i].first;
    } else
      ans += v[i].second;
  }
  cout << ans << endl;
  return 0;
}
