#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  char o, f = 1;
  while (o = getchar(), o < 48)
    if (o == 45) f = -f;
  do x = (x << 3) + (x << 1) + (o ^ 48);
  while (o = getchar(), o > 47);
  return x * f;
}
const int maxn = 1e5 + 5;
long long prea[maxn], pred[maxn], d[maxn], a[maxn], n, k;
int main() {
  d[0] = 1e9;
  n = rd();
  k = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  for (int i = 1; i <= n; i++) d[i] = rd();
  for (int i = 1; i <= n; i++) prea[i] = prea[i - 1] + a[i];
  for (int i = 1; i <= n; i++) pred[i] = pred[i - 1] + a[i];
  if (k >= 2) {
    long long mn = 1e9;
    long long ans = 0;
    for (int i = 1; i < n; i++) mn = min(mn, d[i]);
    ans = max(a[n] - d[n], ans);
    ans = max(ans, prea[n] - mn);
    printf("%lld\n", ans);
  } else if (k == 1) {
    long long ans = 0;
    for (int i = 2; i <= n; i++) ans = max(ans, prea[n] - prea[i - 1] - d[i]);
    long long cnt = -d[1];
    long long sum = prea[n];
    for (int i = 2; i <= n; i++)
      ans = max(ans, sum - a[i] + cnt + max(0ll, a[i] - d[i]));
    int mn1 = 0, mn2 = 0;
    for (int i = 1; i <= n; i++)
      if (d[i] < d[mn1]) mn1 = i;
    for (int i = 1; i <= n; i++)
      if (i != mn1 && d[i] < d[mn2]) mn2 = i;
    ans = max(ans, sum - d[mn1] - d[mn2]);
    long long now = 0, mmn = 1e9;
    for (int i = 1; i < n; i++) {
      now += a[i];
      mmn = min(mmn, d[i]);
      ans = max(ans, now - mmn);
    }
    printf("%lld\n", ans);
  } else {
    long long ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, prea[n] - prea[i - 1] - d[i]);
    printf("%lld\n", ans);
  }
  return 0;
}
