#include <bits/stdc++.h>
using namespace std;
inline void boostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) {
  return (p1.first - p1.second < p2.first - p2.second);
}
int n, k, i, ans;
pair<int, int> p[200200];
int main() {
  boostIO();
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> p[i].first;
  for (int i = 0; i < n; ++i) cin >> p[i].second;
  sort(p, p + n, cmp);
  for (i = 0; i < k; ++i) ans += p[i].first;
  for (i = k; i < n; ++i) ans += min(p[i].first, p[i].second);
  cout << ans << endl;
  return 0;
}
