#include <bits/stdc++.h>
using namespace std;
int n, K;
long long sum;
pair<int, int> a[200003];
inline bool CMP(const pair<int, int> A, const pair<int, int> B) {
  return A.first - A.second < B.first - B.second;
}
int main() {
  int i, cnt;
  cin >> n >> K;
  for (i = 1; i <= n; ++i) cin >> a[i].first;
  for (i = 1; i <= n; ++i) cin >> a[i].second;
  cnt = 0;
  sum = 0LL;
  for (i = 1; i <= n; ++i)
    if (a[i].first <= a[i].second) {
      cnt++;
      sum += (1LL * a[i].first);
    }
  if (cnt >= K) {
    for (i = 1; i <= n; ++i)
      if (a[i].first > a[i].second) sum += (1LL * a[i].second);
    cout << sum << "\n";
    return 0;
  }
  sort(a + 1, a + n + 1, CMP);
  for (i = 1; i <= n; ++i)
    if (a[i].first - a[i].second > 0) {
      if (cnt < K) {
        cnt++;
        sum += (1LL * a[i].first);
      } else
        sum += (1LL * a[i].second);
    }
  cout << sum << "\n";
  return 0;
}
