#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A& a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
  if (a < b) a = b;
}
using ll = long long;
using Pi = pair<long long, long long>;
using Pl = pair<ll, ll>;
using Ti = tuple<long long, long long, long long>;
using Tl = tuple<ll, ll, ll>;
const long long INF = 1LL << 55;
struct edge {
  long long to, capacity, cost, rev;
  edge() {}
  edge(long long to, long long capacity, long long cost, long long rev)
      : to(to), capacity(capacity), cost(cost), rev(rev) {}
};
struct PrimalDual {
  vector<vector<edge> > graph;
  vector<long long> potential, mincost, prevv, preve;
  PrimalDual(long long V)
      : graph(V), potential(V), mincost(V), prevv(V), preve(V) {}
  void add_edge(long long from, long long to, long long capacity,
                long long cost) {
    graph[from].push_back(
        edge(to, capacity, cost, (long long)graph[to].size()));
    graph[to].push_back(
        edge(from, 0, -cost, (long long)graph[from].size() - 1));
  }
  long long min_cost_flow(long long source, long long sink, long long f) {
    long long ret = 0;
    fill(potential.begin(), potential.end(), 0);
    fill(prevv.begin(), prevv.end(), -1);
    fill(preve.begin(), preve.end(), -1);
    while (f > 0) {
      priority_queue<Pi, vector<Pi>, greater<Pi> > que;
      fill(mincost.begin(), mincost.end(), INF);
      mincost[source] = 0;
      que.push(Pi(0, source));
      while (!que.empty()) {
        Pi p = que.top();
        que.pop();
        long long v = p.second;
        if (mincost[v] < p.first) continue;
        for (long long i = 0; i < (long long)graph[v].size(); i++) {
          edge& e = graph[v][i];
          long long dual_cost =
              mincost[v] + e.cost + potential[v] - potential[e.to];
          if (e.capacity > 0 && dual_cost < mincost[e.to]) {
            mincost[e.to] = dual_cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            que.push(Pi(mincost[e.to], e.to));
          }
        }
      }
      if (mincost[sink] == INF) return -1;
      for (long long v = 0; v < (long long)graph.size(); v++)
        potential[v] += mincost[v];
      long long d = f;
      for (long long v = sink; v != source; v = prevv[v])
        d = min(d, graph[prevv[v]][preve[v]].capacity);
      f -= d;
      ret += d * potential[sink];
      for (long long v = sink; v != source; v = prevv[v]) {
        edge& e = graph[prevv[v]][preve[v]];
        e.capacity -= d;
        graph[v][e.rev].capacity += d;
      }
    }
    return ret;
  }
};
signed main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N), B(N);
  for (long long i = 0; i < (N); i++) cin >> A[i];
  for (long long i = 0; i < (N); i++) cin >> B[i];
  PrimalDual mcf(5000);
  long long src = 4998, snk = 4999;
  long long INF = 1001001001;
  for (long long i = 0; i < (N); i++) {
    mcf.add_edge(src, i, 1, A[i]);
    mcf.add_edge(i, i + N, INF, 0);
    mcf.add_edge(i + N, snk, 1, B[i]);
    if (i + 1 != N) mcf.add_edge(i + N, i + 1 + N, INF, 0);
  }
  cout << mcf.min_cost_flow(src, snk, K) << endl;
  return 0;
}
