#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  int a[200001];
  vector<int> good;
  vector<int> bad;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    if (k > a[i]) {
      int cur = a[i] - k;
      good.push_back(cur);
    }
    if (a[i] >= k) {
      int cur = a[i] - k;
      bad.push_back(cur);
    }
    ans = ans + k;
  }
  sort(bad.begin(), bad.end());
  for (int i = 0; i < good.size(); i++) {
    ans = ans + good[i];
  }
  int temp = good.size();
  k = k - min(k, temp);
  for (int i = 0; i < bad.size() && i < k; i++) {
    ans = ans + bad[i];
  }
  cout << ans;
}
