#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using vl = vector<ll>;
using pll = pair<ll, ll>;
using mll = map<ll, ll>;
using vvl = vector<vl>;
using md = double;
template <typename T>
istream& operator>>(istream& c, vector<T>& v) {
  for (auto& i1 : v) c >> i1;
  return c;
}
template <typename T1, typename T2>
istream& operator>>(istream& c, pair<T1, T2>& p) {
  c >> p.first >> p.second;
  return c;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2> p) {
  return c << p.first << ' ' << p.second;
}
const ll mod = 1000000007;
mt19937_64 rng(0xDEADBEEF);
template <typename T>
T binpow_mod(T a, ll b, ll c = mod) {
  if (b == 1) return a;
  if (b & 1) return binpow_mod(a, b - 1, c) * a % c;
  T res = binpow_mod(a, b >> 1, c);
  return res * res % c;
}
template <typename T>
T binpow(T a, ll b) {
  if (b == 1) return a;
  if (b & 1) return binpow(a, b - 1) * a;
  T res = binpow(a, b >> 1);
  return res * res;
}
class dsu {
  vl v;
  ll Sz;

 public:
  dsu(ll sz) : v(sz), Sz(sz) {
    for (ll i = 0; i < ll(sz); i++) v[i] = i;
  }
  ll get(ll i) {
    if (i == v[i]) return v[i];
    return v[i] = get(v[i]);
  }
  ll operator[](ll i) { return get(i); }
  void join(ll a, ll b) {
    Sz -= get(a) != get(b);
    if (rng() % 2) {
      v[get(a)] = get(b);
    } else {
      v[get(b)] = get(a);
    }
  }
  ll size() const { return Sz; }
};
namespace geom {
pll operator+(pll a, pll b) { return {a.first + b.first, a.second + b.second}; }
pll operator-(pll a, pll b) { return {a.first - b.first, a.second - b.second}; }
pll operator-(pll a) { return {-a.first, -a.second}; }
pll operator*(pll a) { return {-a.second, a.first}; }
ll operator*(pll a, pll b) { return a.first * b.first + a.second * b.second; }
}  // namespace geom
ll gcd(ll a, ll b) {
  while (a) tie(a, b) = pll{b % a, a};
  return b;
}
class TIn {};
const TIn vIn;
template <typename TValue>
struct TInContainer {
  TValue Value;
};
template <typename TValue>
TInContainer<TValue> operator>>(const TValue& value, const TIn vIn) {
  return {value};
}
template <typename TValue>
bool operator>>(const TInContainer<TValue>& e, const set<TValue>& v) {
  return v.find(e) != v.end();
}
template <typename TValue, typename TWhatever>
bool operator>>(const TInContainer<TValue>& e,
                const map<TValue, TWhatever>& v) {
  return v.find(e) != v.end();
}
template <typename TValue>
void operator+=(set<TValue>& c, const TValue& v) {
  c.insert(v);
}
template <typename TValue>
void operator+=(multiset<TValue>& c, const TValue& v) {
  c.insert(v);
}
template <typename TValue>
void operator+=(vector<TValue>& c, const TValue& v) {
  c.push_back(v);
}
template <typename TValue>
void operator+=(queue<TValue>& c, const TValue& v) {
  c.push(v);
}
template <typename TValue>
void operator+=(priority_queue<TValue>& c, const TValue& v) {
  c.push(v);
}
template <typename TValue>
void operator-=(set<TValue>& c, const TValue& v) {
  c.erase(v);
}
template <typename TValue>
void operator-=(multiset<TValue>& c, const TValue& v) {
  c.erase(c.find(v));
}
template <typename TValue, typename TWhatever>
void operator-=(map<TValue, TWhatever>& c, const TValue& v) {
  c.erase(v);
}
template <typename TValue>
TValue operator--(set<TValue>& c) {
  TValue ans = *c.begin();
  c.erase(c.begin());
  return ans;
}
template <typename TValue>
TValue operator--(multiset<TValue>& c) {
  TValue ans = *c.begin();
  c.erase(c.begin());
  return ans;
}
template <typename TValue>
TValue operator--(vector<TValue>& c) {
  TValue ans = c.back();
  c.pop_back();
  return ans;
}
template <typename TValue>
TValue operator--(queue<TValue>& c) {
  TValue ans = c.front();
  c.pop();
  return ans;
}
template <typename TValue>
TValue operator--(priority_queue<TValue>& c) {
  TValue ans = c.top();
  c.pop();
  return ans;
}
template <typename TValue>
void operator^=(set<TValue>& c, const TValue& v) {
  if (c.find(v) != c.end())
    c.erase(v);
  else
    c.insert(v);
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.sync_with_stdio(0);
  cout.tie(0);
  using namespace geom;
  ll n, k;
  cin >> n >> k;
  vl a(n), b(n);
  cin >> a >> b;
  vector<pll> v(n);
  for (bool fcheck = true; fcheck;)
    for (auto it2 = b.begin(); fcheck;)
      for (auto it3 = v.begin(); fcheck;)
        for (auto& i1 : a)
          for (fcheck = it2 != b.end() && it3 != v.end(); fcheck;)
            for (auto& i2 = *it2++; fcheck;)
              for (auto& i3 = *it3++; fcheck; fcheck = false) i3 = pll{i1, i2};
  sort(v.begin(), v.end(), [](const pll& a, const pll& b) {
    return a.first - a.second < b.first - b.second;
  });
  ll ans = 0;
  for (ll i = 0; i < ll(k); i++) ans += v[i].first;
  for (ll i = k; i < n; i++) ans += min(v[i].first, v[i].second);
  cout << ans;
  return 0;
}
