#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void ff() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
void in_out_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  ff();
  int n, k;
  cin >> n >> k;
  vector<long long> vec1(n), vec2(n);
  for (int i = 0; i < n; i++) cin >> vec1[i];
  for (int j = 0; j < n; j++) cin >> vec2[j];
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) v.push_back(make_pair(vec1[i] - vec2[i], i));
  sort(v.begin(), v.end());
  long long sum = 0;
  for (int i = 0; i < k; i++) sum += vec1[v[i].second];
  for (int i = k; i < n; i++) sum += min(vec1[v[i].second], vec2[v[i].second]);
  cout << sum << endl;
  return 0;
}
