#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2222;
long long a[MAXN], b[MAXN];
pair<long long, int> dp[MAXN], nxt[MAXN];
int n, k;
pair<long long, int> solve(long long x) {
  fill(dp + 1, dp + n + 2, pair<long long, int>(1e18, 0));
  dp[0] = pair<long long, int>(0, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      pair<long long, int> cnd1, cnd2, cnd3, cnd4;
      cnd1 =
          pair<long long, int>(dp[j].first + a[i] + b[i] - x, dp[j].second + 1);
      cnd2 = pair<long long, int>(dp[j + 1].first + b[i] - x,
                                  dp[j + 1].second + 1);
      if (j == 0)
        cnd3 = pair<long long, int>(1e18, 0);
      else
        cnd3 = pair<long long, int>(dp[j - 1].first + a[i], dp[j - 1].second);
      nxt[j] = min({dp[j], cnd1, cnd2, cnd3});
    }
    memcpy(dp, nxt, sizeof(dp));
  }
  return dp[0];
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &b[i]);
  }
  long long s = 0, e = 2e9;
  while (s != e) {
    long long m = (s + e + 1) / 2;
    if (solve(m).second > k)
      e = m - 1;
    else
      s = m;
  }
  cout << solve(s).first + s * k;
}
