#include <bits/stdc++.h>
using namespace std;
long long A[100005];
long long D[100005];
long long qzh[100005];
long long hzh[100005];
long long ans[100005];
long long dp[100005];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%lld", &A[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &D[i]);
  for (int i = n; i >= 1; i--) {
    hzh[i] = A[i] + hzh[i + 1];
    dp[i] = max(dp[i + 1], hzh[i] - D[i]);
  }
  long long MIN = D[1];
  for (int i = 1; i <= n; i++) {
    MIN = min(MIN, D[i]);
    qzh[i] = qzh[i - 1] + A[i];
    ans[i] = max(dp[i + 1], qzh[i] - MIN + dp[i + 1]);
  }
  if (k == 0) {
    long long res = 0;
    for (int i = 1; i <= n; i++) {
      res = max(res, dp[i]);
    }
    cout << res << endl;
  } else if (k == 1) {
    long long res = 0;
    for (int i = 1; i < n; i++) {
      res = max(res, ans[i]);
    }
    MIN = min(A[n], D[n]);
    for (int i = n - 1; i >= 1; i--) {
      dp[i] = hzh[i] - D[i];
      res = max(res, dp[i] - MIN);
      MIN = min(MIN, min(A[i], D[i]));
    }
    cout << res << endl;
  } else {
    long long res = 0;
    for (int i = 1; i < n; i++) {
      res = max(res, qzh[n] - D[i]);
    }
    res = max(res, A[n] - D[n]);
    cout << res << endl;
  }
  return 0;
}
