#include <bits/stdc++.h>
using namespace std;
const int N = 114514;
long long a[N], d[N], mn[N], s[N], b[N], q[N], kkr;
int n, k, mx;
int main() {
  d[0] = 1919810;
  scanf("%d%d", &n, &k);
  mn[n + 1] = 1919810;
  for (int i = (1); i <= (n); i++) scanf("%lld", &a[i]), q[i] = q[i - 1] + a[i];
  for (int i = (1); i <= (n); i++) {
    scanf("%lld", &d[i]);
    if (d[i] < d[mx] && i != n) mx = i;
  }
  for (int i = (n); i >= (1); i--)
    s[i] = s[i + 1] + a[i], mn[i] = min(a[i], mn[i + 1]);
  if (k >= 2) {
    printf("%lld", max(0 * 1ll, max(s[1] - d[mx], a[n] - d[n])));
    return 0;
  }
  for (int i = (1); i <= (n); i++)
    b[i] = s[i] - d[i] - (i == 1 && k == 1) * mn[2];
  for (int i = (n); i >= (1); i--) b[i] = max(b[i + 1], b[i]);
  if (k == 0) {
    printf("%lld", max(0 * 1ll, b[1]));
    return 0;
  }
  kkr = max(0ll, s[1] - a[n] - d[mx]);
  kkr = max(b[1], kkr);
  sort(d + 1, d + n + 1);
  kkr = max(s[1] - d[1] - d[2], kkr);
  printf("%lld", kkr);
}
