#include <bits/stdc++.h>
using namespace std;
long long psum[100002];
long long a[100002];
long long d[100002];
long long as[100002];
long long pm[100002];
long long dp[100002];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    psum[i] += psum[i - 1] + a[i];
  }
  as[n] = a[n];
  for (int i = n - 1; i >= 1; i--) as[i] = min(as[i + 1], a[i]);
  long long ans = 0;
  pm[0] = 1e17;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &d[i]), pm[i] = min(pm[i - 1], d[i]);
  for (int i = n; i >= 1; i--)
    dp[i] = max(dp[i + 1], psum[n] - psum[i - 1] - d[i]);
  if (k == 0)
    ans = dp[1];
  else if (k == 1) {
    ans = dp[2];
    ans = max(ans, psum[n - 1] - pm[n - 1]);
    ans = max(ans, psum[n] - pm[n - 1] - d[n]);
    for (int i = 1; i <= n - 1; i++) ans = max(ans, psum[i] - d[i] + dp[i + 1]);
    for (int i = 1; i <= n - 2; i++)
      ans = max(ans, a[i] - d[i] + psum[n] - psum[i + 1]);
    for (int i = 1; i <= n - 1; i++)
      ans = max(ans, psum[n] - psum[i - 1] - d[i] - as[i + 1]);
  } else {
    ans = dp[1];
    ans = max(ans, psum[n] - pm[n - 1]);
  }
  printf("%lld\n", ans);
}
