#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, i, e, f, g, n, m, k, l, ans;
pair<int, pair<int, int> > A[200005];
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> A[i].second.first;
  for (i = 1; i <= n; i++) {
    cin >> A[i].second.second;
    A[i].first = A[i].second.first - A[i].second.second;
  }
  sort(A + 1, A + 1 + n);
  for (i = 1; i <= n; i++) {
    if (A[i].first <= 0) {
      ans += A[i].second.first;
      k--;
    } else if (k > 0) {
      ans += A[i].second.first;
      k--;
    } else
      ans += A[i].second.second;
  }
  cout << ans;
}
