#include <bits/stdc++.h>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template <class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (auto &&i : a) scanf("%d", &i);
  for (auto &&i : b) scanf("%d", &i);
  ll ans = accumulate(b.begin(), b.end(), 0LL);
  GPQ<int> Q;
  for (int i = 0; i < n; ++i) {
    Q.emplace(a[i] - b[i]);
  }
  for (int i = 0; i < k; ++i) {
    ans += Q.top();
    Q.pop();
  }
  while (!Q.empty() && Q.top() < 0) {
    ans += Q.top();
    Q.pop();
  }
  cout << ans << "\n";
  return 0;
}
