#include <bits/stdc++.h>
using namespace std;
int n, k;
long long d[100005], a[100005];
long long rsum[100005], minn[100005], f[100005];
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", &d[i]);
  long long sum = 0;
  for (int i = n; i >= 1; i--) {
    rsum[i] = rsum[i + 1] + a[i];
    sum += a[i];
  }
  minn[1] = d[1];
  for (int i = 2; i <= n; i++) minn[i] = min(minn[i - 1], d[i]);
  for (int i = n; i >= 1; i--) f[i] = max(rsum[i] - d[i], f[i + 1]);
  if (k == 0)
    printf("%lld", max(a[n] - d[n], max(0LL, f[1])));
  else if (k == 1) {
    long long maxx = 0LL;
    for (int i = 2; i <= n; i++) maxx = max(sum - d[1] - d[i], maxx);
    for (int i = 2; i <= n; i++) maxx = max(sum - d[1] - a[i], maxx);
    for (int i = 1; i < n; i++)
      maxx = max(maxx, max(rsum[1] - rsum[i + 1] - minn[i], 0LL) + f[i + 1]);
    for (int i = 1; i <= n; i++)
      maxx = max(maxx, max(f[2] + max(0LL, a[1] - d[1]), a[n] - d[n]));
    printf("%lld", max(a[n] - d[n], max(0LL, maxx)));
  } else {
    long long maxx = 0LL;
    maxx = max(maxx, sum - minn[n - 1]);
    printf("%lld", max(a[n] - d[n], max(0LL, maxx)));
  }
  return 0;
}
