#include <bits/stdc++.h>
using namespace std;
const long long N = 2205;
long long n, k, s, t, tt;
long long a[N], b[N];
const long long P = 4405;
const long long E = 200005;
long long to[E], nx[E], h[P], v[E], w[E], tot = 1;
inline void add(long long a, long long b, long long c, long long d) {
  to[++tot] = b;
  nx[tot] = h[a];
  h[a] = tot;
  v[tot] = c;
  w[tot] = d;
}
inline void link(long long a, long long b, long long c, long long d) {
  add(a, b, c, d);
  add(b, a, 0, -d);
}
long long dis[P], fl[P], lp[P], le[P];
bool vis[P];
queue<long long> Q;
const long long inf = 1e18;
inline bool spfa() {
  memset(vis, 0, sizeof vis);
  memset(dis, 0x3f, sizeof dis);
  dis[s] = 0;
  lp[t] = -1;
  fl[s] = inf;
  Q.push(s);
  while (!Q.empty()) {
    long long u = Q.front();
    Q.pop();
    vis[u] = 0;
    for (long long i = h[u]; i; i = nx[i])
      if (v[i]) {
        if (dis[to[i]] > dis[u] + w[i]) {
          dis[to[i]] = dis[u] + w[i];
          lp[to[i]] = u;
          le[to[i]] = i;
          fl[to[i]] = min(fl[u], v[i]);
          if (!vis[to[i]]) {
            vis[to[i]] = 1;
            Q.push(to[i]);
          }
        }
      }
  }
  if (lp[t] == -1)
    return 0;
  else
    return 1;
}
long long mf, mc;
inline void mfmc() {
  mf = 0;
  mc = 0;
  while (spfa()) {
    mf += fl[t];
    mc += fl[t] * dis[t];
    for (long long i = t; i != s; i = lp[i]) {
      v[le[i]] -= fl[t];
      v[le[i] ^ 1] += fl[t];
    }
  }
}
inline long long read() {
  long long f = 0, s = 0;
  char c = getchar();
  while (c > '9' || c < '0') f = (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    s = (s << 3) + (s << 1) + (c ^ '0'), c = getchar();
  return f ? -s : s;
}
signed main() {
  n = read();
  k = read();
  s = n * 2 + 1;
  tt = s + 1;
  t = s + 2;
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) b[i] = read();
  for (long long i = 1; i <= n; i++) link(s, i, 1, a[i]);
  for (long long i = 1; i <= n; i++) link(i + n, tt, 1, b[i]);
  for (long long i = 1; i <= n; i++) link(i, i + n, inf, 0);
  for (long long i = 1; i < n; i++) link(i + n, i + 1, inf, 0);
  link(tt, t, k, 0);
  mfmc();
  printf("%lld", mc);
  return 0;
}
