#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m;
  pair<int, pair<int, int> > arr[n];
  int arr1[n], arr2[n];
  for (int i = 0; i < n; ++i) cin >> arr1[i];
  for (int i = 0; i < n; ++i) cin >> arr2[i];
  for (int i = 0; i < n; ++i) {
    arr[i].second.first = arr1[i];
    arr[i].second.second = arr2[i];
    arr[i].first = arr[i].second.first - arr[i].second.second;
  }
  sort(arr, arr + n);
  long long sum = 0;
  if (n == m) {
    for (int i = 0; i < n; ++i) sum += arr[i].second.first;
    cout << sum << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (m > 0) {
      sum += arr[i].second.first;
      --m;
    } else {
      if (arr[i].second.first > arr[i].second.second)
        sum += arr[i].second.second;
      else
        sum += arr[i].second.first;
    }
  }
  cout << sum << endl;
  return 0;
}
