#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int k;
int ans;
int num;
struct P {
  int x, y, ans;
} LL[200005];
bool cmd(P a, P b) { return a.ans < b.ans; }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> LL[i].x;
  }
  for (int i = 1; i <= n; i++) {
    cin >> LL[i].y;
    LL[i].ans = LL[i].x - LL[i].y;
  }
  sort(LL + 1, LL + 1 + n, cmd);
  for (int i = 1; i <= m; i++) {
    ans += LL[i].x;
  }
  for (int i = m + 1; i <= n; i++) {
    ans += min(LL[i].x, LL[i].y);
  }
  cout << ans << endl;
  return 0;
}
