#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const N = 1e5 + 10;
int n, k;
ll a[N], d[N];
ll suf[N];
ll pre[N];
int minval, minvalpos;
int mincost, mincostpos;
int main() {
  minval = (0x3f3f3f3f);
  mincost = (0x3f3f3f3f);
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (i != 1 && i != n) {
      if (a[i] < minval) {
        minval = a[i];
        minvalpos = i;
      }
    }
    if (i == 1)
      pre[i] = a[i];
    else
      pre[i] = pre[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &d[i]);
    if (i != n) {
      if (d[i] < mincost) {
        mincost = d[i];
        mincostpos = i;
      }
    }
    suf[i] = pre[n] - pre[i - 1];
  }
  if (k >= 2) {
    printf("%lld\n", max(0LL, max(pre[n] - mincost, a[n] - d[n])));
  } else if (k == 0) {
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
      ans = max(ans, suf[i] - d[i]);
    }
    printf("%lld\n", ans);
  } else {
    ll curMinCost = (0x3f3f3f3f);
    ll cir = -(0x3f3f3f3f), li = -(0x3f3f3f3f);
    ll ans = 0LL;
    for (int i = 1; i < n; i++) {
      curMinCost = min(curMinCost, d[i]);
      cir = pre[i] - curMinCost;
      li = suf[i + 1] - d[i + 1];
      ans = max(li + cir, max(ans, max(li, cir)));
    }
    printf("%lld\n", max(0LL, max(ans, pre[n] - minval - d[1])));
  }
  return 0;
}
