#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
inline void priv(vector<int> a) {
  for (int i = 0; i < ((int)(a).size()); ++i)
    printf("%d%c", a[i], i == (int)(a).size() - 1 ? '\n' : ' ');
}
template <typename T>
istream& operator>>(istream& i, vector<T>& v) {
  for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j];
  return i;
}
template <typename T>
string join(const vector<T>& v) {
  stringstream s;
  for (int i = 0; i < ((int)(v).size()); ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  if ((int)(v).size()) o << join(v);
  return o;
}
template <typename T1, typename T2>
istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& v) {
  return o << v.first << "," << v.second;
}
const int MX = 100005, INF = 1001001001;
const long long int LINF = 1e18;
const double eps = 1e-10;
struct Mincost {
  struct Edge {
    int to, nxt;
    long long int co;
    int lim;
    Edge() {}
    Edge(int to, int nxt, long long int co, int lim)
        : to(to), nxt(nxt), co(co), lim(lim) {}
  };
  int n;
  vector<int> head, pre;
  vector<long long int> dist;
  vector<Edge> e;
  Mincost(int n) : n(n), head(n, -1) {}
  void add(int f, int t, long long int c = 0, int l = 1) {
    e.push_back(Edge(t, head[f], c, l));
    head[f] = (int)(e).size() - 1;
    e.push_back(Edge(f, head[t], -c, 0));
    head[t] = (int)(e).size() - 1;
  }
  void dijk(int sv) {
    dist = vector<long long int>(n, INF);
    pre = vector<int>(n, -1);
    priority_queue<pair<long long int, int>, vector<pair<long long int, int>>,
                   greater<pair<long long int, int>>>
        q;
    int v;
    long long int d;
    q.push(pair<long long int, int>(0, sv));
    dist[sv] = 0;
    while ((int)(q).size()) {
      d = q.top().first;
      v = q.top().second;
      q.pop();
      if (dist[v] != d) continue;
      for (int i = head[v]; i != -1; i = e[i].nxt) {
        int u = e[i].to;
        if (e[i].lim && d + e[i].co < dist[u]) {
          dist[u] = d + e[i].co;
          pre[u] = i ^ 1;
          q.push(pair<long long int, int>(dist[u], u));
        }
      }
    }
  }
  long long int solve(int sv, int tv, int flow) {
    long long int res = 0;
    int f;
    while (flow > 0) {
      dijk(sv);
      if (dist[tv] == INF) return -1;
      for (int i = 0; i < (n); ++i)
        for (int j = head[i]; j != -1; j = e[j].nxt) {
          e[j].co += dist[i] - dist[e[j].to];
        }
      f = flow;
      for (int i = tv; i != sv; i = e[pre[i]].to) f = min(f, e[pre[i] ^ 1].lim);
      for (int i = tv; i != sv; i = e[pre[i]].to) {
        e[pre[i] ^ 1].lim -= f, e[pre[i]].lim += f;
      }
      res += dist[tv] * flow;
      flow -= f;
    }
    return res;
  }
};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n), b(n);
  cin >> a >> b;
  int sv = n * 2, tv = sv + 1;
  Mincost g(tv + 1);
  for (int i = 0; i < (n); ++i) {
    g.add(sv, i, a[i], 1);
  }
  for (int i = 0; i < (n); ++i) {
    g.add(i, n + i, 0, 1);
  }
  for (int i = 0; i < (n - 1); ++i) {
    g.add(n + i, n + i + 1, 0, m);
  }
  for (int i = 0; i < (n); ++i) {
    g.add(n + i, tv, b[i], 1);
  }
  cout << g.solve(sv, tv, m) << endl;
  return 0;
}
