#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int maxn = 2250, inf = 2100000000, maxm = 100000;
int a[maxn], b[maxn];
int to[maxm], nx[maxm], cap[maxm], cost[maxm], hd[maxn], cnt;
int S, SS, T;
void addedge(int u, int v, int cp, int w) {
  to[cnt] = v;
  nx[cnt] = hd[u];
  cap[cnt] = cp;
  cost[cnt] = w;
  hd[u] = cnt++;
  to[cnt] = u;
  nx[cnt] = hd[v];
  cap[cnt] = 0;
  cost[cnt] = -w;
  hd[v] = cnt++;
}
long long dist[maxn];
bool upd(long long &x, long long y) {
  if (x == -1 || y < x) return x = y, 1;
  return 0;
}
int q[maxn], he, ta, inq[maxn], pre[maxn];
bool SPFA() {
  memset(dist, -1, sizeof dist);
  dist[S] = 0;
  he = 1, ta = 0;
  q[++ta] = S;
  while (he <= ta) {
    int u = q[he % maxn];
    he++;
    inq[u] = 0;
    for (int i = hd[u]; ~i; i = nx[i]) {
      int v = to[i];
      if (cap[i] && upd(dist[v], dist[u] + cost[i])) {
        pre[v] = i;
        if (!inq[v]) q[(++ta) % maxn] = v, inq[v] = 1;
      }
    }
  }
  return ~dist[T];
}
long long flow() {
  long long ret = 0;
  while (SPFA()) {
    int nw = T, f = inf;
    while (nw != S) {
      f = min(f, cap[pre[nw]]);
      nw = to[pre[nw] ^ 1];
    }
    ret += f * dist[T];
    nw = T;
    while (nw != S) {
      cap[pre[nw]] -= f, cap[pre[nw] ^ 1] += f;
      nw = to[pre[nw] ^ 1];
    }
  }
  return ret;
}
int n, k;
int main() {
  n = rd(), k = rd();
  S = 0, SS = n + 1, T = n + 2;
  memset(hd, -1, sizeof hd);
  cnt = 0;
  addedge(S, SS, k, 0);
  for (int i = int(1); i <= (int)(n); i++) addedge(SS, i, 1, rd());
  for (int i = int(1); i <= (int)(n); i++) addedge(i, T, 1, rd());
  for (int i = int(1); i <= (int)(n - 1); i++) addedge(i, i + 1, inf, 0);
  rt(flow()), putchar('\n');
}
