#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n, k;
int a[N], d[N], mn[N];
long long sum[N], mx[N], mx2[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  long long ans = max(0, a[n] - d[n]);
  if (k == 0) {
    for (int i = 1; i < n; i++) {
      ans = max(ans, sum[n] - sum[i - 1] - d[i]);
    }
    printf("%lld\n", ans);
    return 0;
  }
  if (k > 1) {
    for (int i = 1; i < n; i++) ans = max(ans, sum[n] - d[i]);
    printf("%lld\n", ans);
    return 0;
  }
  for (int i = 2; i <= n; i++) ans = max(ans, sum[n] - d[1] - a[i]);
  for (int i = n; i >= 1; i--)
    mx2[i] = max(mx2[i + 1], sum[n] - sum[i - 1] - d[i]);
  mn[0] = INF;
  for (int i = 1; i <= n; i++) mn[i] = min(mn[i - 1], d[i]);
  for (int i = 1; i < n; i++) {
    ans = max(ans, max(0ll, sum[i] - mn[i]) + mx2[i + 1]);
  }
  printf("%lld\n", ans);
  return 0;
}
