#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long long a[maxn], d[maxn], sum[maxn];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%lld", &d[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    sum[i] += sum[i + 1] + d[i];
    ans = max(ans, sum[i] - a[i]);
  }
  if (k == 0) {
    printf("%lld\n", ans);
    return 0;
  }
  long long ans1 = 0, ans2 = 0;
  long long min_val = 1e9;
  for (int i = 1; i <= n - 1; i++) {
    min_val = min(min_val, a[i]);
    long long cnt = max(sum[1] - sum[i + 1] - min_val, 0ll) +
                    max(sum[i + 1] - a[i + 1], 0ll);
    ans1 = max(ans1, cnt);
    if (i == n - 1) ans2 = max(ans2, max(sum[1] - min_val, d[n] - a[n]));
  }
  if (ans == ans2) {
    for (int i = 1; i <= n - 1; i++) {
      long long cnt =
          max(sum[1] - d[i] - a[i == 1 ? 2 : 1], 0ll) + max(d[i] - a[i], 0ll);
      ans1 = max(ans1, cnt);
    }
    if (k == 1)
      printf("%lld\n", ans1);
    else
      printf("%lld\n", ans2);
  } else {
    if (k == 1) {
      printf("%lld\n", ans1);
    } else
      printf("%lld\n", ans2);
  }
  return 0;
}
