#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 10;
const long long INFF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch<'0' | ch> '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void Out(int aa) {
  if (aa > 9) Out(aa / 10);
  putchar(aa % 10 + '0');
}
struct node {
  int x, y, c, rev;
  long long cost;
};
vector<node> vec[10010];
int n;
long long dis[10010];
int preV[10010], preE[10010];
void add_edge(int x, int y, int c, long long cost) {
  node p1, p2;
  p1.y = y, p1.c = c, p1.cost = cost, p1.rev = vec[y].size();
  vec[x].push_back(p1);
  p2.y = x, p2.c = 0, p2.cost = -cost, p2.rev = vec[x].size() - 1;
  vec[y].push_back(p2);
}
long long min_cost_flow(int s, int t) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  for (int i = 0; i <= n * 2 + 2; i++) dis[i] = INFF;
  dis[s] = 0;
  q.push(pair<long long, int>(0, s));
  while (!q.empty()) {
    pair<long long, int> p1 = q.top();
    q.pop();
    int v = p1.second;
    if (dis[v] >= p1.first) {
      for (int i = 0; i < vec[v].size(); i++) {
        node &p2 = vec[v][i];
        if (p2.c > 0 && dis[p2.y] > dis[v] + p2.cost) {
          dis[p2.y] = dis[v] + p2.cost;
          preV[p2.y] = v;
          preE[p2.y] = i;
          q.push(pair<long long, int>(dis[p2.y], p2.y));
        }
      }
    }
  }
  if (dis[t] == INFF) {
    return -1;
  }
  for (int v = t; v != s; v = preV[v]) {
    node &p2 = vec[preV[v]][preE[v]];
    p2.c--;
    vec[v][p2.rev].c++;
  }
  return dis[t];
}
long long a[10005], b[10005];
int main() {
  int k;
  scanf("%d%d", &n, &k);
  memset(preE, -1, sizeof(preE));
  memset(preV, -1, sizeof(preV));
  for (int i = 0; i <= n; i++) vec[i].clear();
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int j = 1; j <= n; j++) scanf("%lld", &b[j]);
  int s = 0, t = n * 2 + 1;
  for (int i = 1; i <= n; i++) {
    add_edge(s, i, 1, a[i]);
    add_edge(i + n, t, 1, b[i]);
    add_edge(i, i + n, n, 0);
    if (i < n) add_edge(i + n, i + n + 1, n - i, 0);
  }
  long long ans = 0;
  for (int i = 1; i <= k; i++) ans += min_cost_flow(s, t);
  printf("%lld\n", ans);
  return 0;
}
