#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
const int N = 100100;
long long a[N], d[N];
long long pre[N];
long long suf[N];
long long pmn[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i < (n + 1); ++i) cin >> a[i];
  for (int i = 1; i < (n + 1); ++i) cin >> d[i];
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    suf[i] = max(suf[i + 1], pre[n] - pre[i - 1] - d[i]);
  }
  pmn[1] = d[1];
  for (int i = 2; i <= n; i++) pmn[i] = min(pmn[i - 1], d[i]);
  if (k != 1) {
    for (int i = 1; i <= n; i++) {
      ans = max(ans, pre[n] - pre[i - 1] - d[i]);
    }
  } else {
    for (int i = 1; i < n; i++) {
      ans = max(ans, max(0LL, a[n] - d[n]) + max(0LL, pre[n - 1] - d[i]));
    }
    for (int i = 1; i < n; i++) {
      ans = max(ans, pre[n] - d[i + 1] - pmn[i]);
    }
    for (int i = 2; i < n; i++) {
      ans = max(ans, pre[n] - pre[i - 1] - d[i] + max(0LL, a[1] - d[1]));
    }
    ans = max(ans, pre[n] - d[1] - d[2]);
    for (int i = 1; i < n; i++) {
      ans = max(ans, pre[n] - a[i + 1] - d[1] + max(0LL, a[i + 1] - d[i + 1]));
    }
  }
  if (k >= 2) {
    long long mn = 1e9;
    for (int i = 1; i < (n); ++i) mn = min(mn, d[i]);
    ans = max(ans, pre[n] - mn);
  }
  cout << ans << "\n";
}
