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