#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 3;
int a[maxn], b[maxn], c[maxn], o[maxn];
int n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int(i) = 0; (i) < (n); ++i) cin >> a[i];
  for (int(i) = 0; (i) < (n); ++i) cin >> b[i];
  for (int(i) = 0; (i) < (n); ++i) c[i] = a[i] - b[i], o[i] = i;
  sort(o, o + n, [](int a, int b) { return c[a] < c[b]; });
  int ans = 0;
  for (int(i) = 0; (i) < (k); ++i) ans += a[o[i]];
  for (int i = k; i < n; ++i) ans += min(a[o[i]], b[o[i]]);
  cout << ans << '\n';
  return 0;
}
