#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, n, k, ans = 0;
  cin >> n >> k;
  int a[n], b[n];
  vector<pair<int, int> > v;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    cin >> b[i];
    v.push_back(make_pair(a[i] - b[i], i));
  }
  sort(v.begin(), v.end());
  for (i = 0; i < n; i++) {
    if (i < k || v[i].first <= 0) {
      ans += a[v[i].second];
    } else {
      ans += b[v[i].second];
    }
  }
  cout << ans;
}
