#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const unsigned long long seed = 13331;
const long long inf = 1e18;
int n, k;
long long a[maxn], c[maxn], b[maxn];
int main() {
  scanf("%d%d", &n, &k);
  long long sum = 0;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), sum += a[i];
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  long long ans = 0;
  if (k >= 2) {
    sort(b + 1, b + n);
    ans = max(ans, sum - b[1]);
    ans = max(ans, a[n] - b[n]);
  } else if (!k) {
    for (int i = n - 1; i >= 1; i--) a[i] += a[i + 1];
    for (int i = 1; i <= n; i++) ans = max(ans, a[i] - b[i]);
  } else {
    c[n + 1] = 0;
    long long Min = a[2];
    for (int i = n; i >= 1; i--) c[i] = c[i + 1] + a[i];
    for (int i = 2; i <= n; i++) {
      ans = max(ans, c[i] - b[i]);
      Min = min(Min, a[i]);
    }
    ans = max(ans, sum - Min - b[1]);
    sort(b + 1, b + n);
    ans = max(ans, sum - a[n] - b[1]);
    sort(b + 1, b + 1 + n);
    ans = max(ans, sum - b[1] - b[2]);
  }
  printf("%lld\n", ans);
  return 0;
}
