#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
using namespace std;
const int MAX = 5e5 + 5;
const long long MOD = 1000000007;
const long long MOD2 = 2010405347;
const long long INF = 9e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 500;
long long n, k, x[MAX], y[MAX], le, ri, mid, res;
priority_queue<pair<long long, long long> > pq;
pair<long long, long long> f(long long lambda) {
  long long ret = 0, cnt = 0;
  for (int i = 1; i <= n; ++i) {
    ret += x[i];
    pq.push({-x[i], 0});
    pq.push({y[i] - lambda, 1});
    pq.pop();
  }
  for (int i = 1; i <= n; ++i) {
    ret += pq.top().first;
    cnt += pq.top().second;
    pq.pop();
  }
  return {ret, cnt};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> x[i];
  for (int i = 1; i <= n; ++i) cin >> y[i];
  le = 0, ri = 10e10;
  while (le <= ri) {
    mid = le + ri >> 1;
    if (f(mid).second <= k)
      res = mid, le = mid + 1;
    else
      ri = mid - 1;
  }
  cout << f(res).first + res * k << '\n';
  return 0;
}
