#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100000 + 5;
const long long INF = 1e14 + 5;
struct abc {
  int t, a, i;
};
bool operator<(abc a, abc b) { return a.t < b.t; }
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
bool inRange(int n, int x, int y) { return x > 0 && y > 0 && x <= n && y <= n; }
int main(int argc, char* argv[]) {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n), b(n);
  vector<pair<int, int> > c(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    c[i] = make_pair(a[i] - b[i], i);
  }
  sort(c.begin(), c.end());
  int summ = 0;
  for (int i = 0; i < k; ++i) {
    int to = c[i].second;
    summ += a[to];
    a[to] = 0;
    b[to] = 0;
  }
  for (int i = 0; i < n; ++i) {
    summ += min(a[i], b[i]);
  }
  printf("%d", summ);
  return 0;
}
