#include <bits/stdc++.h>
using namespace std;
long long n, k, sum;
struct st {
  int x, y, dis;
} a[202020];
bool cmp(st a, st b) { return a.dis < b.dis; }
bool rev(st a, st b) { return a.y < b.y; }
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i].x;
  for (int i = 0; i < n; i++) {
    cin >> a[i].y;
    a[i].dis = a[i].x - a[i].y;
  }
  sort(a, a + n, cmp);
  for (int i = 0; i < k; i++) sum += a[i].x;
  for (int i = k; i < n; i++) sum += min(a[i].x, a[i].y);
  cout << sum;
}
