#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> w[9999999];
int main() {
  long long l = 0, p = 0, t2 = 0, k = 0, o = 0;
  long long o1 = 0, o2 = 0, o3 = 0, o4 = 0, x, y;
  long long t, s;
  cin >> t >> s;
  long long a1[t], a2[t];
  for (unsigned int i = 0; i < t; i++) {
    cin >> a1[i];
  }
  for (unsigned int i = 0; i < t; i++) {
    cin >> a2[i];
  }
  for (unsigned int i = 0; i < t; i++) {
    if (a1[i] <= a2[i]) {
      l++;
      o = o + a1[i];
    } else {
      x = a1[i] - a2[i];
      y = i;
      o = o + a2[i];
      w[k] = {x, y};
      k++;
    }
  }
  sort(w, w + k);
  if (s > l) {
    for (unsigned int j = 0; j < s - l; j++) {
      o = o + w[j].first;
    }
  }
  cout << o << endl;
}
