#include <bits/stdc++.h>
using namespace std;
const int MaxN(100003);
int a[MaxN], b[MaxN];
long long solve1(int n) {
  long long res = 0;
  long long ans = 0;
  for (int i = n; i; i--) {
    res += b[i];
    ans = max(ans, res - a[i]);
  }
  return ans;
}
long long c[MaxN];
long long solve2(int n) {
  long long res = 0;
  int Mn = 10000000;
  for (int i = 1; i <= n; i++) {
    res += b[i];
    Mn = min(Mn, a[i]);
    c[i] = max(0ll, res - Mn);
  }
  res = 0;
  long long ans = 0;
  for (int i = n; i > 1; i--) {
    res += b[i];
    ans = max(ans, c[i - 1] + max(res - a[i], 0ll));
  }
  return ans;
}
long long solve3(int n) {
  long long res = 0;
  int Mn = 10000000;
  for (int i = 1; i <= n; i++) {
    res += b[i];
    Mn = min(Mn, b[i]);
  }
  return res - Mn - a[1];
}
int main() {
  int n, K;
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (K >= 2) {
    long long res = 0;
    long long ans = 0;
    for (int i = 1; i <= n; i++) res += b[i];
    for (int i = 1; i < n; i++) ans = max(ans, res - a[i]);
    ans = max(ans, (long long)b[n] - a[n]);
    printf("%lld\n", ans);
  } else if (K == 0)
    printf("%lld\n", solve1(n));
  else
    printf("%lld\n", max(solve2(n), solve3(n)));
  return 0;
}
