#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 2207;
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a *= a) ret = 1ll * ret * a % M;
  return ret;
}
struct node {
  long long to, cap, cost, rev;
  node(int t = 0, int c = 0, int n = 0, int r = 0)
      : to(t), cap(c), cost(n), rev(r) {}
};
vector<node> edge[maxn];
void addedge(int from, int to, long long cap, long long cost) {
  edge[from].push_back(node(to, cap, cost, edge[to].size()));
  edge[to].push_back(node(from, 0, -cost, edge[from].size() - 1));
}
int n, m, V;
long long dis[maxn];
bool mark[maxn];
int pre_v[maxn], pre_e[maxn];
queue<int> Q;
long long mincostflow(int s, int t, long long f) {
  long long ret = 0, d;
  int i, v;
  while (f) {
    memset(dis, 0x3f, sizeof(dis));
    memset(mark, 0, sizeof(mark));
    while (Q.size()) Q.pop();
    dis[s] = 0;
    Q.push(s);
    while (Q.size()) {
      v = Q.front();
      mark[v] = 0;
      Q.pop();
      for (i = 0; i < edge[v].size(); i++) {
        node &e = edge[v][i];
        if (e.cap > 0 && dis[e.to] > dis[v] + e.cost) {
          dis[e.to] = dis[v] + e.cost;
          pre_v[e.to] = v;
          pre_e[e.to] = i;
          if (!mark[e.to]) Q.push(e.to), mark[e.to] = 1;
        }
      }
    }
    if (dis[t] == INF) return -1;
    d = f;
    for (v = t; v != s; v = pre_v[v]) d = min(d, edge[pre_v[v]][pre_e[v]].cap);
    f -= d;
    ret += d * dis[t];
    for (v = t; v != s; v = pre_v[v]) {
      node &e = edge[pre_v[v]][pre_e[v]];
      e.cap -= d;
      edge[v][e.rev].cap += d;
    }
    if (d == 0) break;
  }
  return ret;
}
int i;
long long j, k;
int main() {
  scanf("%d%I64d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &j);
    addedge(0, i, 1, j);
  }
  for (i = 1; i <= n - 1; i++) addedge(i, i + 1, k, 0);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &j);
    addedge(i, n + 1, 1, j);
  }
  V = n + 2;
  printf("%I64d", mincostflow(0, n + 1, k));
}
