#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e18;
struct rib {
  long long b, u, c, f;
  size_t back;
};
void add_rib(vector<vector<rib> >& g, long long a, long long b, long long u,
             long long c) {
  rib r1 = {b, u, c, 0, g[b].size()};
  rib r2 = {a, 0, -c, 0, g[a].size()};
  g[a].push_back(r1);
  g[b].push_back(r2);
}
long long minCostFlow(long long n, long long maxFlow, long long s, long long t,
                      vector<vector<rib> >& g) {
  long long ans = 0;
  long long flow = 0, cost = 0;
  for (long long k = maxFlow; k <= maxFlow; k++) {
    while (flow < k) {
      vector<long long> id(n, 0);
      vector<long long> d(n, INF);
      vector<long long> q(n);
      vector<long long> p(n);
      vector<size_t> p_rib(n);
      long long qh = 0, qt = 0;
      q[qt++] = s;
      d[s] = 0;
      while (qh != qt) {
        long long v = q[qh++];
        id[v] = 2;
        if (qh == n) qh = 0;
        for (size_t i = 0; i < g[v].size(); ++i) {
          rib& r = g[v][i];
          if (r.f < r.u && d[v] + r.c < d[r.b]) {
            d[r.b] = d[v] + r.c;
            if (id[r.b] == 0) {
              q[qt++] = r.b;
              if (qt == n) qt = 0;
            } else if (id[r.b] == 2) {
              if (--qh == -1) qh = n - 1;
              q[qh] = r.b;
            }
            id[r.b] = 1;
            p[r.b] = v;
            p_rib[r.b] = i;
          }
        }
      }
      if (d[t] == INF) break;
      long long addflow = k - flow;
      for (long long v = t; v != s; v = p[v]) {
        long long pv = p[v];
        size_t pr = p_rib[v];
        addflow = min(addflow, g[pv][pr].u - g[pv][pr].f);
      }
      for (long long v = t; v != s; v = p[v]) {
        long long pv = p[v];
        size_t pr = p_rib[v], r = g[pv][pr].back;
        g[pv][pr].f += addflow;
        g[v][r].f -= addflow;
        cost += g[pv][pr].c * addflow;
      }
      flow += addflow;
    }
    ans = max(ans, cost);
    if (flow < k) break;
  }
  return ans;
}
vector<pair<long long, long long> > A, B;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<vector<rib> > g(n + 2);
  for (long long i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    add_rib(g, 0, i, 1, a);
  }
  for (long long i = 1; i <= n; i++) {
    long long b;
    cin >> b;
    add_rib(g, i, n + 1, 1, b);
  }
  for (long long i = 1; i < n; i++) {
    add_rib(g, i, i + 1, k, 0);
  }
  cout << minCostFlow(n + 2, k, 0, n + 1, g) << "\n";
  return 0;
}
