#include <bits/stdc++.h>
using namespace std;
int to[200020], head[200020], nxt[200020], cost[200020], cap[200020], cnt;
void init() { memset(head, -1, sizeof head); }
void add_Edge(int S, int T, int c, int w) {
  nxt[cnt] = head[S], cap[cnt] = c, cost[cnt] = w, to[cnt] = T, head[S] = cnt++;
  nxt[cnt] = head[T], cap[cnt] = 0, cost[cnt] = -w, to[cnt] = S,
  head[T] = cnt++;
}
const long long INF = 1e14;
long long dist[200020];
int prv[200020];
bool vis[200020];
long long SPFA(int S, int T, int vet) {
  queue<int> Q;
  fill(prv, prv + vet, -1);
  fill(dist, dist + vet, INF);
  Q.push(S);
  dist[S] = 0, vis[S] = true;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop(), vis[x] = false;
    for (int id = head[x]; ~id; id = nxt[id])
      if (cap[id]) {
        int y = to[id];
        if (dist[y] > dist[x] + cost[id]) {
          dist[y] = dist[x] + cost[id];
          prv[y] = id;
          if (!vis[y]) Q.push(y), vis[y] = true;
        }
      }
  }
  if (!~prv[T]) {
    return INF;
  }
  for (int cur = T; cur != S; cur = to[cur ^ 1]) {
    cur = prv[cur];
    cap[cur]--;
    cap[cur ^ 1]++;
  }
  return dist[T];
}
int a[200020], b[200020], n, k;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  int S = 0, T = 2 * n + 1;
  init();
  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 += SPFA(S, T, T + 1);
  cout << ans << endl;
}
