#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x);
template <typename T>
void write(T x);
template <typename T>
void writesp(T x);
template <typename T>
void writeln(T x);
const long long N = 3e5 + 6;
long long head[N], to[N << 1], MabLcdG[N << 1], tot = 1, c[N << 1], w[N << 1];
inline void add(long long x, long long y, long long u, long long v) {
  to[++tot] = y;
  MabLcdG[tot] = head[x];
  head[x] = tot;
  c[tot] = u;
  w[tot] = v;
}
inline void Link(long long x, long long y, long long u, long long v) {
  add(x, y, u, v);
  add(y, x, 0, -v);
}
long long n, K;
long long a[N], b[N];
long long S, S1, T;
long long res;
long long dis[N], pre[N], incf[N], last[N];
queue<long long> q;
bool vis[N];
inline bool spfa() {
  while (q.size()) q.pop();
  memset(dis, 0x3f, sizeof dis);
  dis[S] = 0;
  q.push(S);
  pre[T] = -1;
  incf[S] = 0x7fffffff;
  while (q.size()) {
    long long x = q.front();
    q.pop();
    vis[x] = false;
    for (register long long i = head[x], ver; i; i = MabLcdG[i]) {
      ver = to[i];
      if (!c[i]) continue;
      if (dis[ver] > dis[x] + w[i]) {
        dis[ver] = dis[x] + w[i];
        incf[ver] = min(incf[x], c[i]);
        pre[ver] = x;
        last[ver] = i;
        if (!vis[ver]) {
          q.push(ver);
          vis[ver] = true;
        }
      }
    }
  }
  return pre[T] != -1;
}
inline void update() {
  long long x = T;
  while (x != S) {
    c[last[x]] -= incf[T];
    c[last[x] ^ 1] += incf[T];
    x = pre[x];
  }
  res += dis[T] * incf[T];
}
int main() {
  read(n);
  read(K);
  for (register long long i = 1; i <= n; i++) read(a[i]);
  for (register long long j = 1; j <= n; j++) read(b[j]);
  S = n + 1;
  T = S + 1;
  S1 = T + 1;
  Link(S, S1, K, 0);
  for (register long long i = 1; i <= n; i++) Link(S1, i, 1, a[i]);
  for (register long long i = 1; i <= n; i++) Link(i, T, 1, b[i]);
  for (register long long i = 1; i < n; i++) Link(i, i + 1, K, 0);
  while (spfa()) update();
  writeln(res);
}
template <typename T>
void read(T &x) {
  x = 0;
  int t = 1;
  char wn = getchar();
  while (wn < '0' || wn > '9') {
    if (wn == '-') t = -1;
    wn = getchar();
  }
  while (wn >= '0' && wn <= '9') {
    x = x * 10 + wn - '0';
    wn = getchar();
  }
  x *= t;
}
template <typename T>
void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x <= 9) {
    putchar(x + '0');
    return;
  }
  write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writesp(T x) {
  write(x);
  putchar(' ');
}
template <typename T>
void writeln(T x) {
  write(x);
  putchar('\n');
}
