#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void in(T &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
template <typename T1, typename T2>
void in(T1 &x, T2 &y) {
  in(x);
  return in(y);
}
template <typename T1, typename T2, typename T3>
void in(T1 &x, T2 &y, T3 &z) {
  in(x);
  in(y);
  return in(z);
}
template <typename T1, typename T2, typename T3, typename T4>
void in(T1 &x, T2 &y, T3 &z, T4 &w) {
  in(x);
  in(y);
  in(z);
  return in(w);
}
int a[200009], b[200009], d[200009];
int main() {
  int n, k, cnt = 0;
  in(n, k);
  for (int i = 0; i < n; i++) in(a[i]);
  for (int i = 0; i < n; i++) in(b[i]);
  int j = 0;
  for (int i = 0; i < n; i++)
    if (a[i] <= b[i])
      k--;
    else
      d[j++] = a[i] - b[i];
  sort(d, d + j);
  for (int i = 0; i < j && k > 0; i++) cnt += d[i], k--;
  for (int i = 0; i < n; i++) cnt += min(a[i], b[i]);
  printf("%d\n", cnt);
  return 0;
}
