#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> now(n), after(n);
  for (int i = 0; i < n; ++i) {
    cin >> now[i];
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> after[i];
    sum += after[i];
    after[i] = now[i] - after[i];
  }
  sort(after.begin(), after.end());
  for (int i = 0; --k >= 0 || after[i] < 0; ++i) {
    sum += after[i];
  }
  cout << sum << '\n';
  return 0;
}
