#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k;
int a[N], d[N];
long long suffixMax[N];
long long prefixMax[N];
void read() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
  }
}
long long zeroK() {
  long long ret = 0;
  long long sum = 0;
  for (int i = n; i >= 1; i--) {
    sum += a[i];
    ret = max(ret, sum - d[i]);
  }
  return ret;
}
long long atLeastTwoK() {
  long long ret = 0;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += a[i];
  }
  for (int i = 1; i < n; i++) {
    ret = max(ret, sum - d[i]);
  }
  ret = max(ret, 1ll * a[n] - d[n]);
  return ret;
}
long long atLeastOneK() {
  long long ret = 0;
  long long sum = 0;
  for (int i = n; i >= 1; i--) {
    sum += a[i];
    suffixMax[i] = max(sum - d[i], suffixMax[i + 1]);
  }
  sum = a[1];
  int mins = d[1];
  for (int i = 2; i < n; i++) {
    sum += a[i];
    mins = min(mins, d[i]);
    long long cur = max(0ll, sum - mins) + suffixMax[i + 1];
    ret = max(ret, cur);
  }
  for (int i = 2; i <= n; i++) {
    ret = max(ret, suffixMax[i]);
  }
  sum = a[n] + a[n - 1];
  int minA = a[n - 1];
  int minD = d[n - 1];
  for (int i = n - 2; i >= 1; i--) {
    sum += a[i];
    ret = max(ret, sum - minA - d[i]);
    ret = max(ret, sum - minD - d[i]);
    if (a[i] < minA) minA = a[i];
    if (d[i] < minD) minD = d[i];
  }
  return ret;
}
int main() {
  read();
  long long ret = 0;
  if (k == 0) {
    ret = zeroK();
  } else if (k == 1) {
    ret = atLeastOneK();
  } else if (k >= 2) {
    ret = atLeastTwoK();
  }
  printf("%lld\n", ret);
  return 0;
}
