#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, next;
  long long v, c;
} e[(2300 * 3) << 1];
int ne = 1, head[2300], from[2300];
bool inq[2300], vis[2300];
int a[2300], b[2300], n, k;
int S, T, SS;
long long dis[2300], ans;
queue<int> q;
void ins(int u, int v, long long f, int c) {
  ne++;
  e[ne].to = v;
  e[ne].v = f;
  e[ne].c = c;
  e[ne].next = head[u];
  head[u] = ne;
}
void insert(int u, int v, long long f, int c) {
  ins(u, v, f, c);
  ins(v, u, 0, -c);
}
bool spfa() {
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  dis[S] = 0;
  q.push(S);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    inq[now] = 0;
    for (int i = head[now]; i; i = e[i].next) {
      int v = e[i].to;
      if (e[i].v == 0) continue;
      if (dis[v] > dis[now] + e[i].c) {
        dis[v] = dis[now] + e[i].c;
        if (!inq[v]) {
          q.push(v);
          inq[v] = 1;
        }
      }
    }
  }
  if (dis[T] != 0x3f3f3f3f3f3f3f3f) return 1;
  return 0;
}
long long dfs(int x, long long f) {
  if (x == T) {
    ans += dis[x] * f;
    return f;
  }
  long long ret = 0;
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (e[i].v == 0 || vis[v]) continue;
    if (dis[v] == dis[x] + e[i].c) {
      long long tmp = dfs(v, min(f, e[i].v));
      f -= tmp;
      e[i].v -= tmp;
      e[i ^ 1].v += tmp;
      ret += tmp;
      if (f == 0) break;
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  S = 0;
  SS = n + 1;
  T = n + 2;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  insert(S, SS, k, 0);
  for (int i = 1; i <= n; i++) {
    insert(SS, i, 1, a[i]);
    insert(i, T, 1, b[i]);
    if (i != n) insert(i, i + 1, 0x3f3f3f3f3f3f3f3f, 0);
  }
  while (spfa()) dfs(S, 0x3f3f3f3f3f3f3f3f);
  cout << ans << endl;
  return 0;
}
