#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
using namespace std;
template <typename T = int>
T yh() {
  T ret = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == EOF) return -1;
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) ret = (ret << 3) + (ret << 1) + (c ^ 48), c = getchar();
  return f ? -ret : ret;
}
template <typename T>
void yh(T& ret) {
  ret = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == EOF) return ret = -1, void();
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) ret = (ret << 3) + (ret << 1) + (c ^ 48), c = getchar();
  ret = f ? -ret : ret;
}
const int maxn = 1e5 + 5;
int n;
int k;
long long a[maxn], d[maxn];
long long s[maxn];
int main() {
  n = yh(), k = yh();
  for (register int i = (1); i <= (n); i++) a[i] = yh(), s[i] = s[i - 1] + a[i];
  for (register int i = (1); i <= (n); i++) d[i] = yh();
  if (k == 0) {
    long long ans = 0;
    for (register int i = (1); i <= (n); i++) {
      ans = max(ans, s[n] - s[i - 1] - d[i]);
    }
    cout << ans << '\n';
  } else if (k >= 2) {
    long long ans = 0;
    for (register int i = (1); i <= (n - 1); i++) {
      ans = max(ans, s[n] - d[i]);
    }
    ans = max(ans, a[n] - d[n]);
    cout << ans << '\n';
  } else {
    long long ans = 0;
    for (register int i = (1); i <= (n - 1); i++) {
      ans = max(ans, s[n - 1] - d[i]);
    }
    long long mn = 0x3f3f3f3f;
    for (register int i = (2); i <= (n - 1); i++) {
      mn = min(mn, d[i]);
      ans = max(ans, s[n] - mn - d[i + 1]);
    }
    if (a[1] - d[1] >= 0 && a[2] - d[2] >= 0) {
      ans = max(ans, s[n] - d[1] - d[2]);
    } else if (a[1] - d[1] >= 0) {
      ans = max(ans, s[n] - a[2] - d[1]);
    } else if (a[2] - d[2] >= 0) {
      ans = max(ans, s[n] - a[1] - d[2]);
    }
    for (register int i = (2); i <= (n - 1); i++) {
      ans = max(ans, s[n] - s[i - 1] - d[i]);
    }
    for (int i = 1; i + 2 <= n; i++) {
      ans = max(ans, s[n] - a[i + 1] - d[1]);
    }
    cout << ans << '\n';
  }
  return 0;
}
