#include <bits/stdc++.h>
const int max = 1e5 + 10;
using namespace std;
int main() {
  long long t, cur, key;
  long long sum = 0;
  cin >> t >> key;
  int a[t + 5], b[t + 5], c[t + 5];
  for (int i = 0; i < t; i++) {
    scanf("%ld", &a[i]);
  }
  for (int i = 0; i < t; i++) {
    scanf("%ld", &b[i]);
    sum += b[i];
    c[i] = a[i] - b[i];
  }
  sort(c, c + t);
  cur = 0;
  for (int i = 0; i < t; i++) {
    if (cur < key || c[i] < 0) {
      sum += c[i];
      cur++;
    } else
      break;
  }
  cout << sum << endl;
}
