#include <bits/stdc++.h>
using namespace std;
long long n, k, a[1000006], d[1000006], s, x, it, sl, st, minv, ans1,
    sum[1000006], ans2, ans3;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> d[i];
  s = 0;
  sum[n - 1] = a[n - 1];
  for (long long i = n - 2; i >= 0; i--) sum[i] = sum[i + 1] + a[i];
  if (k > 1) {
    ans1 = 0;
    x = *min_element(d, d + n - 1);
    for (long long i = 0; i < n; i++) s += a[i];
    ans1 = max(s - x, 0ll);
    ans2 = a[n - 1] - d[n - 1];
    cout << max(ans1, ans2) << endl;
  } else if (!k) {
    ans1 = 0;
    for (long long i = 0; i < n; i++) ans1 = max(ans1, sum[i] - d[i]);
    cout << ans1 << endl;
  } else {
    for (long long i = 0; i < n; i++) s += a[i];
    sl = a[0];
    st = s - sl;
    minv = d[0];
    ans1 = 0;
    for (long long i = 1; i < n - 1; i++) {
      minv = min(minv, d[i]);
      st -= a[i];
      sl += a[i];
      ans1 = max(ans1, max(sl - minv, 0ll) + max(st - d[i + 1], 0ll));
    }
    ans2 = 0;
    for (long long i = 1; i < n; i++) ans2 = max(ans2, sum[i] - d[i]);
    ans3 = 0;
    for (long long i = 1; i < n - 1; i++) {
      ans3 = max(ans3, s - a[i] - d[0] + max(0ll, a[i] - d[i]));
    }
    cout << max(max(ans1, ans2), ans3) << endl;
  }
  return 0;
}
