#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  pair<long long int, long long int> pr1[n + 1];
  pair<long long int, long long int> pr2[n + 1];
  long long int a[n + 1], b[n + 1], c[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    pr1[i].second = a[i];
  }
  for (long long int i = 1; i <= n; i++) {
    cin >> b[i];
    pr1[i].first = b[i];
  }
  long long int j = 0, sum = 0;
  for (long long int i = n; i >= 1; i--) {
    if (pr1[i].second < pr1[i].first) {
      sum += pr1[i].second;
      k--;
    } else {
      pr2[j].second = pr1[i].second;
      pr2[j++].first = pr1[i].second - pr1[i].first;
    }
  }
  sort(pr2, pr2 + j);
  for (long long int i = 0; i < j; i++) {
    if (k > 0) {
      sum += pr2[i].second;
      k--;
    } else
      sum += (pr2[i].second - pr2[i].first);
  }
  cout << sum << endl;
}
