#include <bits/stdc++.h>
using namespace std;
long long n, k, sum, a[300005], b[300005], suf[300005], ans, mn, mn1, sum1,
    pr[300005];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  mn = 1e9;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    if (i != n) mn = min(mn, b[i]);
  }
  for (int i = n; i >= 1; i--) {
    suf[i] = suf[i + 1] + a[i];
    ans = max(ans, suf[i] - b[i]);
  }
  if (k == 0) {
    cout << ans << endl;
    return 0;
  }
  if (k >= 2) {
    cout << max(0ll, max(sum - mn, a[n] - b[n])) << endl;
    return 0;
  }
  mn1 = 1e9;
  for (int i = 1; i <= n; i++) {
    mn1 = min(mn1, b[i]);
    sum1 += a[i];
    pr[i] = sum1 - mn1;
  }
  ans = 0;
  for (int i = 1; i < n; i++) {
    ans = max(ans, pr[i] + max(0ll, suf[i + 1] - b[i + 1]));
  }
  mn1 = 1e9;
  mn1 = a[n];
  for (int i = n - 1; i >= 1; i--) {
    if (i == 1) {
      ans = max(ans, suf[i] - b[i] - mn1);
      break;
    }
    ans = max(ans, suf[i] - b[i]);
    mn1 = min(mn1, a[i]);
  }
  cout << ans << endl;
}
