#include <bits/stdc++.h>
using namespace std;
long long A[110000];
long long D[110000];
long long psumA[110000];
long long psumD[110000];
long long mxE[110000];
long long mnD[110000];
void solve() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> D[i];
  for (int i = 0; i < N; i++) psumA[i + 1] = psumA[i] + A[i];
  for (int i = 0; i < N; i++) psumD[i + 1] = psumD[i] + D[i];
  long long ans = 0;
  if (K == 0) {
    for (int i = 0; i < N; i++) ans = max(ans, psumA[N] - psumA[i] - D[i]);
  } else if (K % 2 == 0) {
    ans = max(ans, psumA[N] - *min_element(D, D + N - 1));
    ans = max(ans, A[N - 1] - D[N - 1]);
  } else if (K == 1) {
    mnD[0] = D[0];
    for (int i = 1; i < N; i++) mnD[i] = min(mnD[i - 1], D[i]);
    ans = max(ans, psumA[N - 1] - mnD[N - 2]);
    ans = max(ans, psumA[N] - mnD[N - 2] - D[N - 1]);
    ans = max(ans, A[N - 1] - D[N - 1]);
    for (int i = 0; i < N - 1; i++) mxE[i] = psumA[N] - psumA[i] - D[i];
    for (int i = N - 2; i >= 0; i--) mxE[i] = max(mxE[i], mxE[i + 1]);
    for (int i = 0; i < N - 1; i++) {
      ans = max(ans, psumA[i + 1] - mnD[i] +
                         max({0LL, mxE[i + 1], A[N - 1] - D[N - 1]}));
    }
    for (int i = 1; i < N; i++) ans = max(ans, psumA[N] - psumA[i] - D[i]);
    ans = max(ans, psumA[N] - D[0] - *min_element(A + 1, A + N - 1));
  } else if (K >= 3 && K % 2 == 1) {
    ans = max(ans, psumA[N] - *min_element(D, D + N - 1));
    ans = max(ans, A[N - 1] - D[N - 1]);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  if (0) {
    int T;
    cin >> T;
    while (T--) solve();
  } else {
    solve();
  }
  return 0;
}
