#include <bits/stdc++.h>
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  int discount[n], sum = 0;
  for (int i = 0; i < n; i++) {
    sum += b[i];
    discount[i] = a[i] - b[i];
  }
  std::sort(discount, discount + n);
  int i = 0;
  while (i < k || discount[i] < 0) {
    sum += discount[i++];
  }
  printf("%d\n", sum);
  return 0;
}
