#include <bits/stdc++.h>
using namespace std;
long long a[100010], d[100010], s[100010], suf[100010];
int main() {
  int n, k;
  cin >> n >> k;
  long long int mn;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> d[i];
  s[0] = 1e7;
  for (int i = 1; i <= n; i++) s[i] = min(s[i - 1], d[i]);
  for (int i = n; i; i--) suf[i] = suf[i + 1] + a[i];
  long long ans = 0;
  if (k == 0) {
    for (int i = 1; i <= n; i++) ans = max(ans, suf[i] - d[i]);
    cout << ans;
    return 0;
  } else if (k > 1) {
    ans = max(ans, max(suf[1] - s[n - 1], a[n] - d[n]));
    cout << ans;
    return 0;
  } else {
    for (int i = 2; i <= n; i++)
      ans = max(ans,
                max(0ll, suf[1] - suf[i] - s[i - 1]) + max(0ll, suf[i] - d[i]));
    for (int i = 1; i < n - 1; i++)
      ans = max(ans, suf[1] - a[1 + i] - d[1] + max(0ll, a[i + 1] - d[i + 1]));
    cout << ans;
    return 0;
  }
}
