#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
long long int POWER[65];
long long int aonb(long long int a, long long int b) {
  long long int ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    if (ret >= MOD) ret %= MOD;
    if (a >= MOD) a %= MOD;
    b >>= 1;
  }
  return ret;
}
void precompute() {
  POWER[0] = 1;
  for (int i = 1; i < 63; i++) POWER[i] = POWER[i - 1] << 1LL;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<pair<int, pair<int, int> > > A(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i].second.first);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i].second.second);
  }
  for (int i = 0; i < n; i++) {
    A[i].first = A[i].second.first - A[i].second.second;
  }
  sort(A.begin(), A.end());
  int count = 0;
  for (int i = 0; i < k; i++) count += A[i].second.first;
  for (int i = n - 1; i >= k; i--) {
    count += min(A[i].second.second, A[i].second.first);
  }
  cout << count;
  return 0;
}
