#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b % 2) ret = (ret * a) % 1000000007;
    a = (a * a) % 1000000007;
    b = b / 2;
  }
  return ret;
}
long long ie(long long a) { return power(a, 1000000007 - 2); }
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
int a[200005];
int b[200005];
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  vector<pair<int, int> > v;
  for (int i = 0; i < N; i++) {
    v.push_back(make_pair(min(0, -a[i] + b[i]), a[i]));
  }
  long long sum = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    if (i < (N - K))
      sum += (v[i].second + v[i].first);
    else
      sum += v[i].second;
  }
  cout << sum;
  return 0;
}
