#include <bits/stdc++.h>
using namespace std;
long long int pow_mod(long long int a, long long int b) {
  long long int res = 1;
  while (b != 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return res;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  long long int d[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) cin >> d[i];
  long long int suf[n];
  long long int ka[n + 1];
  ka[n] = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    if (i == n - 1)
      suf[i] = a[i];
    else
      suf[i] = suf[i + 1] + a[i];
    ka[i] = max(ka[i + 1], suf[i] - d[i]);
  }
  long long int ans = 0;
  if (k == 0) {
    for (long long int i = 0; i < n; i++) ans = max(ans, -d[i] + suf[i]);
  } else if (k >= 2) {
    long long int sum = 0;
    for (long long int i = 0; i < n; i++) sum += a[i];
    for (long long int i = 0; i < n - 1; i++) ans = max(ans, sum - d[i]);
    ans = max(ans, a[n - 1] - d[n - 1]);
  } else {
    long long int mxi[n];
    long long int sum[n];
    for (long long int i = 0; i < n; i++) {
      if (i == 0)
        mxi[i] = d[i];
      else
        mxi[i] = min(mxi[i - 1], d[i]);
      if (i == 0)
        sum[i] = a[i];
      else
        sum[i] = sum[i - 1] + a[i];
    }
    for (long long int i = 0; i < n - 1; i++) {
      long long int res = suf[0] - suf[i + 1];
      long long int lk = max(0LL, ka[i + 1]);
      ans = max(ans, max(0LL, sum[i] - mxi[i]) + lk);
    }
    ans = max(ans, a[n - 1] - d[n - 1]);
    ans = max(ans, a[0] - d[0] + suf[2]);
    long long int mx = 0;
    for (long long int i = 0; i < n - 2; i++) {
      mx = max(mx, suf[i] - d[i]);
      ans = max(ans, mx - a[i + 1]);
    }
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) solve();
  return 0;
}
