#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10;
int n, k;
long long a[maxN + 1], d[maxN + 1], tp[maxN + 1];
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 ans = max(0ll, a[n] - d[n]);
  if (k == 0) {
    long long sum = 0;
    for (int i = n; i >= 1; i--) {
      sum += a[i];
      ans = max(ans, sum - d[i]);
    }
    printf("%lld\n", ans);
    return 0;
  }
  if (k == 1) {
    long long mn = 1e18, sum = 0;
    for (int i = 1; i < n; i++) mn = min(mn, d[i]), sum += a[i];
    ans = max(ans, sum - mn);
    sum = 0;
    for (int i = n; i >= 1; i--) {
      sum += a[i];
      tp[i] = max(tp[i + 1], sum - d[i]);
    }
    sum = a[1];
    mn = d[1];
    for (int i = 2; i < n; i++) {
      sum += a[i];
      mn = min(mn, d[i]);
      ans = max(ans, sum - mn + tp[i + 1]);
    }
    sum = 0;
    for (int i = n; i > 1; i--) sum += a[i], ans = max(ans, sum - d[i]);
    sum += a[1];
    for (int i = 2; i < n; i++) {
      ans = max(ans, sum - a[i] - d[1]);
      ans = max(ans, sum - d[i] - d[1]);
    }
    printf("%lld\n", ans);
    return 0;
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) sum += a[i];
  long long mn = 1e18;
  for (int i = 1; i < n; i++) mn = min(mn, d[i]);
  ans = max(ans, sum - mn);
  printf("%lld\n", ans);
  return 0;
}
