#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long neg = 1, num = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - '0';
  return neg * num;
}
long long n, k, s[200010], a[200010], d[200010], mi[200010], pre[200010],
    suf[200010];
signed main() {
  n = read();
  k = read();
  for (long long i = 1; i <= n; i++) a[i] = read(), s[i] = s[i - 1] + a[i];
  for (long long i = 1; i <= n; i++) d[i] = read();
  mi[1] = d[1];
  for (long long i = 2; i <= n; i++) mi[i] = min(mi[i - 1], d[i]);
  suf[n] = max(0ll, a[n] - d[n]);
  for (long long i = n - 1; i >= 1; i--)
    suf[i] = max(suf[i + 1], s[n] - s[i - 1] - d[i]);
  pre[1] = max(0ll, s[n] - d[1]);
  for (long long i = 2; i <= n; i++)
    pre[i] = max(pre[i - 1], s[n] - s[i - 1] - d[i]);
  long long ans = 0, sum = 0;
  if (k == 0) ans = max(ans, suf[1]);
  if (k >= 1) {
    for (long long i = 1; i <= n - 1; i++)
      ans = max(ans, max(0ll, s[i] - mi[i]) + suf[i + 1]);
    for (long long i = 2; i <= n - 1; i++)
      ans =
          max(ans, max(suf[i + 1], pre[i - 1] - a[i]) + max(0ll, a[i] - d[i]));
  }
  if (k >= 2) ans = max(ans, s[n] - mi[n - 1]);
  printf("%lld\n", ans);
  return 0;
}
