#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops, no-stack-protector")
#pragma GCC target("avx,avx2,fma")
class min_cost_flow {
 public:
  struct edge_node {
    long long to;
    long long capacity, flow;
    long long cost;
    long long reverse_id;
  };
  long long VERYBIG = 1LL << 61;
  long long n, f, mf, totalcost;
  long long s, t;
  vector<vector<edge_node>> adj;
  vector<long long> pp, ppid;
  min_cost_flow(long long nn, long long start, long long terminal) {
    n = nn;
    s = start;
    t = terminal;
    adj.clear();
    adj.resize(nn);
  }
  void add_path(long long a, long long b, long long forward_capacity,
                long long backward_capacity = 0, long long forward_cost = 0,
                long long backward_cost = 0) {
    long long ida = adj[a].size(), idb = adj[b].size();
    adj[a].push_back({b, forward_capacity, 0, forward_cost, idb});
    adj[b].push_back({a, backward_capacity, 0, backward_cost, ida});
  }
  void clear_flow() {
    long long i;
    for (i = 0; i < n; i++) {
      for (auto p : adj[i]) p.flow = 0;
    }
  }
  void augment(long long v, long long maxflow) {
    if (v == s) {
      f = maxflow;
    } else if (pp[v] != -1) {
      long long parent = pp[v], pid = ppid[v],
                rid = adj[parent][pid].reverse_id;
      long long available_flow =
          adj[parent][pid].capacity - adj[parent][pid].flow;
      if (maxflow < available_flow)
        augment(parent, maxflow);
      else
        augment(parent, available_flow);
      adj[parent][pid].flow += f;
      adj[v][rid].flow -= f;
      totalcost += f * (adj[parent][pid].cost - adj[v][rid].cost);
    }
  }
  void solve_flow() {
    mf = 0;
    totalcost = 0;
    while (1) {
      long long i, j, k;
      vector<long long> dist;
      dist.assign(n, VERYBIG);
      dist[s] = 0;
      queue<long long> q;
      q.push(s);
      pp.assign(n, -1);
      ppid.assign(n, -1);
      while (!q.empty()) {
        long long u = q.front(), v;
        q.pop();
        for (i = 0; i < adj[u].size(); i++) {
          v = adj[u][i].to;
          if ((adj[u][i].flow < adj[u][i].capacity) &&
              (dist[v] > dist[u] + adj[u][i].cost)) {
            dist[v] = dist[u] + adj[u][i].cost;
            q.push(v);
            pp[v] = u;
            ppid[v] = i;
          }
        }
      }
      f = 0;
      augment(t, VERYBIG);
      if (f == 0) break;
      if (f == VERYBIG) break;
      mf += f;
    }
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, kk, i, j, k, ans;
  cin >> n >> kk;
  vector<long long> a(n), b(n);
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) cin >> b[i];
  min_cost_flow fl(n + 3, 0, n + 2);
  for (i = 0; i < n; i++) fl.add_path(0, i + 1, 1, 0, a[i], -a[i]);
  for (i = 0; i < n; i++) fl.add_path(i + 1, n + 1, 1, 0, b[i], -b[i]);
  for (i = 0; i < n - 1; i++) fl.add_path(i + 1, i + 2, n, 0, 0, 0);
  fl.add_path(n + 1, n + 2, kk, 0, 0, 0);
  fl.solve_flow();
  ans = fl.totalcost / 2;
  cout << ans << "\n";
  return 0;
}
