#include <bits/stdc++.h>
using namespace std;
int solve(vector<pair<int, int> >& arr, int k) {
  int ret = 0;
  for (int i = 0; i < k; i++) ret += arr[i].first;
  for (int i = k; i < arr.size(); i++) ret += min(arr[i].first, arr[i].second);
  return ret;
}
bool comp(pair<int, int> a, pair<int, int> b) {
  return (a.first - a.second) < (b.first - b.second);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i].first;
  for (int i = 0; i < n; i++) cin >> arr[i].second;
  sort(arr.begin(), arr.end(), comp);
  cout << solve(arr, k);
}
