#include <bits/stdc++.h>
using namespace std;
long long a[100020];
long long d[100020];
long long dp[100020];
long long mn[100020];
long long e[100020];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long A = 0, D = 0;
  long long mnn = 1e15;
  long long mw = 1e15;
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
    D += d[i];
    if (i == n - 1) continue;
    mw = min(mw, d[i]);
  }
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    A += a[i];
    if (i == n - 1) continue;
    mnn = min(mnn, a[i]);
  }
  long long ans = 0;
  for (long long i = 0; i <= n + 2 + 1; i++) (dp[i]) = 0;
  ;
  long long aa = 0, dd = 0;
  for (long long i = n - 1; i >= 0; i--) {
    dd += d[i];
    dp[i] = max(dp[i], dp[i + 1]);
    dp[i] = max(dp[i], dd - a[i]);
  }
  long long m = 1e15;
  e[0] = d[0];
  for (long long i = 0; i < n; i++) {
    m = min(m, a[i]);
    mn[i] = m;
    if (i > 0) e[i] = e[i - 1] + d[i];
  }
  if (k > 1) {
    ans = max(ans, D - mnn);
  } else {
    if (k == 0) ans = max(ans, dp[0]);
    if (k == 1) {
      ans = max(ans, dp[1]);
      ans = max(ans, D - d[1] - a[0]);
      ans = max(ans, D - a[0] - a[1]);
      for (long long i = 1; i < n; i++) {
        ans = max(ans, dp[i] + max((long long)0, e[i - 1] - mn[i - 1]));
      }
      ans = max(ans, dp[1] + d[0] - a[0]);
      ans = max(ans, D - mw - a[0]);
    }
  }
  cout << max(ans, d[n - 1] - a[n - 1]);
  return 0;
}
