#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * (long long)a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int a[2300], b[2300], cnt, head[4500], p[4500], vis[4500];
long long d[4500];
struct node {
  int v, c, w, _next;
} g[200010];
void add(int a, int b, int c, int w) {
  g[cnt] = {b, c, w, head[a]}, head[a] = cnt++;
  g[cnt] = {a, 0, -w, head[b]}, head[b] = cnt++;
}
const long long INF = 1e18;
bool bfs(int s, int t) {
  for (int i = 0; i < t + 1; i++) d[i] = INF, vis[i] = 0;
  d[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = head[u]; ~i; i = g[i]._next) {
      int j = g[i].v;
      if (d[j] > d[u] + g[i].w && g[i].c) {
        d[j] = d[u] + g[i].w;
        p[j] = i;
        if (!vis[j]) vis[j] = 1, q.push(j);
      }
    }
  }
  return d[t] < INF;
}
int main() {
  int T, i = 0, j, k, ca = 0, m = 250, K, n;
  scanf("%d%d", &n, &K);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  int s = 2 * n, t = s + 1;
  memset(head, -1, sizeof(head));
  for (int i = 0; i < n; i++) {
    add(s, 2 * i, 1, a[i]);
    add(2 * i, 2 * i + 1, 1, 0);
    add(2 * i + 1, t, 1, b[i]);
    if (i < n - 1) {
      add(2 * i, 2 * i + 2, K, 0);
    }
  }
  long long ans = 0, f = 0;
  while (bfs(s, t)) {
    ans += d[t];
    f++;
    if (f == K) break;
    int first = t;
    while (first != s) {
      g[p[first]].c--, g[p[first] ^ 1].c++, first = g[p[first] ^ 1].v;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
