#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const long long N = 100000;
long long n, m;
long long a[N + 1], b[N + 1];
long long Sum[N + 1];
long long mX[N + 2];
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++)
    scanf("%lld", a + i), Sum[i] = Sum[i - 1] + a[i];
  for (long long i = 1; i <= n; i++) scanf("%lld", b + i);
  if (m == 0) {
    long long ans = 0;
    for (long long i = 1; i <= n; i++)
      ans = max(ans, Sum[n] - Sum[i - 1] - b[i]);
    cout << ans;
  } else if (m > 1) {
    long long mn = inf;
    for (long long i = 1; i < n; i++) mn = min(mn, b[i]);
    cout << max(0ll, max(a[n] - b[n], Sum[n] - mn));
  } else {
    for (long long i = n; i; i--)
      mX[i] = max(mX[i + 1], Sum[n] - Sum[i - 1] - b[i]);
    long long mn = inf, ans = 0;
    for (long long i = 1; i < n; i++) {
      mn = min(mn, b[i]);
      if (i > 1) ans = max(ans, Sum[i] - mn + mX[i + 1]);
      if (i < n - 1)
        ans = max(ans, max(mX[i + 1], max(mX[1] - a[i + 1], mX[1] - b[i + 1])));
    }
    cout << ans;
  }
  return 0;
}
