#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a;
  int d[n], p[n];
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    a.push_back({d[i] - p[i], i});
    sum += p[i];
  }
  sort(a.begin(), a.end());
  int s = 0, o = 0, k = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].first < 0) {
      s += p[a[i].second];
      o += d[a[i].second];
      k++;
    } else if (k < m) {
      s += p[a[i].second];
      o += d[a[i].second];
      k++;
    } else
      break;
  }
  cout << o + sum - s;
}
