#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long long prefSumA[maxn];
long long suffSum[maxn];
long long suffMax[maxn];
long long minimD[maxn];
int main() {
  int n, k, i, j;
  long long a[maxn], d[maxn];
  while (scanf("%d %d", &n, &k) != EOF) {
    for (i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    for (i = 1; i <= n; i++) {
      scanf("%lld", &d[i]);
    }
    long long sum = a[n];
    suffMax[n] = max(0LL, a[n] - d[n]);
    suffSum[n] = a[n];
    for (i = n - 1; i >= 1; i--) {
      sum += a[i];
      suffSum[i] = sum;
      suffMax[i] = max(suffMax[i + 1], sum - d[i]);
    }
    prefSumA[1] = a[1];
    minimD[1] = d[1];
    for (i = 2; i <= n; i++) {
      prefSumA[i] = a[i] + prefSumA[i - 1];
      minimD[i] = min(minimD[i - 1], d[i]);
    }
    if (k == 0) {
      printf("%lld\n", suffMax[1]);
      continue;
    }
    long long ans = max(0LL, a[n] - d[n]);
    if (k == 1) {
      long long maksVal = -1000000000;
      for (i = 2; i <= n - 1; i++) {
        maksVal = max(maksVal + a[i - 1], a[i - 1] - d[i - 1]);
        ans = max(ans,
                  maksVal + suffSum[i + 1] + (a[i] > d[i] ? a[i] - d[i] : 0));
        ans = max(ans, suffMax[i + 1]);
      }
      for (i = 2; i <= n; i++) {
        long long jawab = suffSum[i] - d[i];
        ans = max(ans, jawab);
      }
      for (i = 2; i <= n - 1; i++) {
        ans = max(ans, prefSumA[i] - minimD[i] + suffMax[i + 1]);
      }
    } else {
      long long minim = 1000000000;
      long long sum = 0;
      for (i = 1; i <= n; i++) {
        sum += a[i];
        if (i < n) {
          minim = min(minim, d[i]);
        }
      }
      ans = max(ans, sum - minim);
    }
    printf("%lld\n", ans);
  }
  return 0;
};
