#include <bits/stdc++.h>
using namespace std;
const int M = 100005;
long long S[M];
int pre[M], suf[M], A[M], D[M];
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
    S[i] = S[i - 1] + A[i];
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &D[i]);
  pre[1] = D[1];
  suf[n - 1] = A[n - 1];
  for (int i = 2; i <= n; ++i) pre[i] = min(D[i], pre[i - 1]);
  for (int i = n - 2; 1 <= i; --i) suf[i] = min(A[i], suf[i + 1]);
  if (k == 0) {
    long long ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, -D[i] + S[n] - S[i - 1]);
    printf("%lld\n", ans);
  } else if (k == 1) {
    long long ans = 0;
    for (int i = 1; i < n; ++i) {
      ans =
          max(ans, max(0LL, S[i] - pre[i]) + max(0LL, S[n] - S[i] - D[i + 1]));
    }
    for (int i = 1; i < n - 1; ++i) {
      ans = max(ans, -D[i] + S[n] - S[i - 1] - suf[i + 1]);
    }
    printf("%lld\n", ans);
  } else {
    long long ans = max(0LL, S[n] - pre[n - 1]);
    ans = max((long long)A[n] - D[n], ans);
    printf("%lld\n", ans);
  }
  return 0;
}
