#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long INF = 1LL << 60;
int n, k;
long long a[maxn], e[maxn];
long long s[maxn];
long long f[maxn];
long long min_pre[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  long long sum = 0, min_e = INF;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = n; i >= 1; --i) {
    s[i] = a[i] + s[i + 1];
  }
  min_pre[0] = INF;
  for (int i = 1; i <= n; ++i) {
    cin >> e[i];
    min_pre[i] = min(min_pre[i - 1], e[i]);
    if (i != n) min_e = min(min_e, e[i]);
  }
  for (int i = n; i >= 1; --i) {
    f[i] = max(f[i + 1], s[i] - e[i]);
  }
  if (k >= 2) {
    cout << max(0LL, max(sum - min_e, a[n] - e[n])) << endl;
    return 0;
  } else if (k == 0) {
    cout << f[1] << endl;
  } else if (k == 1) {
    long long ans = 0;
    for (int i = 1; i < n; ++i) {
      ans = max(ans, s[1] - s[i + 1] - min_pre[i] + f[i + 1]);
    }
    long long t = 0;
    for (int i = 1; i <= n - 2; ++i) {
      t = max(t, s[i] - e[i]);
      ans = max(ans, t - a[i + 1] + max(a[i + 1] - e[i + 1], 0LL));
      ans = max(ans, f[i + 1]);
    }
    cout << ans << endl;
  }
  return 0;
}
