#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 50, INF = 0x3f3f3f3f3f3f3f3f;
struct edge {
  long long nxt;
  long long to;
  long long cap;
  long long flow;
  long long cst;
};
edge e[MAXN];
long long head[MAXN], now[MAXN], Cnte = 1;
long long N, K, S, T, a[MAXN], b[MAXN], dis[MAXN];
long long sum = 0, Ans1 = 0, Ans2 = 0;
bool vis[MAXN];
queue<long long> q;
void adde(long long u, long long v, long long w, long long c) {
  ++Cnte;
  e[Cnte].to = v;
  e[Cnte].cap = w;
  e[Cnte].cst = c;
  e[Cnte].nxt = head[u];
  head[u] = Cnte;
}
bool SPFA() {
  memset(vis, false, sizeof(vis));
  while (!q.empty()) q.pop();
  for (int i = 1; i <= N + 3; ++i) dis[i] = INF;
  dis[S] = 0;
  q.push(S);
  vis[S] = true;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    now[u] = head[u];
    vis[u] = false;
    for (int i = head[u]; i; i = e[i].nxt) {
      long long v = e[i].to, w = e[i].cst;
      if (e[i].cap > e[i].flow && dis[u] + w < dis[v]) {
        dis[v] = dis[u] + w;
        if (!vis[v]) {
          vis[v] = true;
          q.push(v);
        }
      }
    }
  }
  return dis[T] != INF;
}
long long dfs(long long u, long long flow) {
  if (u == T || flow == 0) return flow;
  vis[u] = true;
  long long res = 0;
  for (int i = now[u]; i; i = e[i].nxt) {
    now[u] = i;
    long long v = e[i].to, w = e[i].cst;
    if (!vis[v] && e[i].cap > e[i].flow && dis[v] == dis[u] + w) {
      long long t = dfs(v, min(flow, e[i].cap - e[i].flow));
      if (t == 0) continue;
      e[i].flow += t;
      e[i ^ 1].flow -= t;
      res += t;
      flow -= t;
      Ans2 += t * w;
      if (flow == 0) break;
    }
  }
  if (res == 0) dis[u] = INF;
  vis[u] = false;
  return res;
}
long long Dinic() {
  long long res = 0;
  while (SPFA()) res += dfs(S, INF);
  return res;
}
void Init() {
  scanf("%lld%lld", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%lld", &a[i]);
  for (int i = 1; i <= N; ++i) scanf("%lld", &b[i]);
}
void Solve() {
  S = N + 1;
  T = N + 2;
  adde(S, N + 3, K, 0);
  adde(N + 3, S, 0, 0);
  for (int i = 1; i <= N; ++i) {
    adde(N + 3, i, 1, a[i]);
    adde(i, N + 3, 0, -a[i]);
    adde(i, T, 1, b[i]);
    adde(T, i, 0, -b[i]);
  }
  for (int i = 1; i < N; ++i) {
    adde(i, i + 1, INF, 0);
    adde(i + 1, i, 0, 0);
  }
  Dinic();
}
void Print() { printf("%lld\n", Ans2); }
int main() {
  Init();
  Solve();
  Print();
  return 0;
}
