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