#include <bits/stdc++.h>
using namespace std;
long long a[100005], d[100005], sum[100005], t[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> d[i];
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  if (k == 0) {
    long long ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, sum[n] - sum[i - 1] - d[i]);
    cout << ans << '\n';
  } else if (k >= 2) {
    long long ans = 0, minn = 0x3f3f3f3f;
    for (int i = 1; i < n; i++) minn = min(d[i], minn);
    ans = sum[n] - minn;
    cout << max(a[n] - d[n], max(ans, 0ll)) << '\n';
  } else {
    long long ans = 0, minn = 0x3f3f3f3f;
    long long mink = d[1];
    for (int i = n; i >= 1; i--) {
      t[i] = max(t[i + 1], sum[n] - sum[i - 1] - d[i]);
    }
    for (int i = 1; i <= n; i++) {
      minn = min(minn, d[i]);
      mink = min(sum[i - 1] + d[i], mink);
      if (i + 2 <= n) {
        ans = max(ans, sum[n] - sum[i] - d[i + 1]);
        ans = max(ans, max(sum[n] - mink - a[i + 1], 0ll) +
                           max(0ll, a[i + 1] - d[i + 1]));
      }
      0, 0;
      if (i > 1 && i < n) {
        ans = max(max(sum[i] - minn, 0ll) + t[i + 1], ans);
      }
      0, 0;
    }
    cout << ans << '\n';
  }
}
