#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y;
} a[200010];
int n, K, ans;
bool cmp(const Point &a, const Point &b) { return a.y - a.x > b.y - b.x; }
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].x);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].y);
  sort(a + 1, a + n + 1, cmp);
  int i;
  for (i = 1; i <= n; ++i) {
    if (i > K && a[i].y - a[i].x < 0) break;
    ans += a[i].x;
  }
  for (; i <= n; ++i) ans += a[i].y;
  printf("%d\n", ans);
  return 0;
}
