#include <bits/stdc++.h>
using namespace std;
const unsigned long long int MOD = 1e9 + 7;
void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}
long long int POW(long long int p, int b) {
  long long int ans = 1LL;
  while (b > 0) {
    if (b & 1) {
      ans = ans * 1LL * p;
    }
    b /= 2;
    p = p * 1LL * p;
  }
  return ans;
}
long long int power(long long int a, long long int b, long long int mod) {
  long long int x = 1;
  long long int y = a;
  while (b > 0) {
    if (b & 1) {
      x = x * y;
      x %= mod;
    }
    y = y * y;
    y %= mod;
    b /= 2;
  }
  return x;
}
long long int add(long long int a, long long int b, long long int m = MOD) {
  long long int x = a + b;
  while (x >= m) x -= m;
  while (x < 0) x += m;
  return x;
}
long long int sub(long long int a, long long int b, long long int m = MOD) {
  long long int x = a - b;
  while (x < 0) x += m;
  while (x >= m) x -= m;
  return x;
}
long long int mul(long long int a, long long int b, long long int m = MOD) {
  long long int x = a * 1ll * b;
  x %= m;
  if (x < 0) x += m;
  return x;
}
const int N = 2e5 + 2;
int n;
int a[N], b[N];
int abhi[N];
int badd[N];
long long int ans = 0;
int k;
int fayda = 0;
vector<pair<int, int> > A, B;
bool used[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    if (a[i] == b[i]) {
      A.push_back(make_pair(0, i));
    } else if (a[i] < b[i]) {
      fayda++;
      A.push_back(make_pair(b[i] - a[i], i));
    } else {
      B.push_back(make_pair(b[i] - a[i], i));
    }
  }
  if (k == n) cout << ans, exit(0);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  ans = 0;
  if ((int)A.size() >= k) {
    while (!A.empty()) {
      ans += a[A.back().second];
      used[A.back().second] = true;
      A.pop_back();
    }
  } else {
    k -= (int)A.size();
    while (!A.empty()) {
      ans += a[A.back().second];
      used[A.back().second] = true;
      A.pop_back();
    }
    while (k--) {
      ans += a[B.back().second];
      used[B.back().second] = true;
      B.pop_back();
    }
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) ans += b[i];
  cout << ans;
}
