#include <bits/stdc++.h>
using namespace std;
int N, K;
int a[2210], b[2210];
int cnt[2210];
long long func(void) {
  int i, j = N;
  int aans = -1, bans = -1, bid = -1;
  long long best = (1ll << 60);
  for (i = N - 1; i >= 0; i--) {
    while (j > i || (j > 0 && cnt[j - 1] > 0)) {
      j--;
      if (b[j] > 0 && (bid == -1 || b[j] < b[bid])) bid = j;
    }
    if (a[i] > 0 && bid != -1 && a[i] + b[bid] < best) {
      best = a[i] + b[bid];
      aans = i;
      bans = bid;
    }
  }
  if (aans < bans) {
    for (i = aans; i < bans; i++) cnt[i]++;
  } else {
    for (i = aans - 1; i >= bans; i--) cnt[i]--;
  }
  a[aans] = b[bans] = 0;
  return best;
}
int main(void) {
  int i;
  cin >> N >> K;
  for ((i) = 0; (i) < (int)(N); (i)++) cin >> a[i];
  for ((i) = 0; (i) < (int)(N); (i)++) cin >> b[i];
  long long ans = 0;
  for ((i) = 0; (i) < (int)(K); (i)++) ans += func();
  cout << ans << endl;
  return 0;
}
