#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
long long n, k;
long long d[100001];
long long a[100001];
long long best[100002];
long long bestp[100002];
long long sum[100002];
long long mn[100001];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = n; i >= 1; i--) sum[i] = a[i] + sum[i + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> d[i];
    mn[i] = d[i];
    if (i > 1) mn[i] = min(mn[i], mn[i - 1]);
  }
  for (long long i = 1; i <= n; i++) {
    best[i] = sum[i] - d[i];
  }
  for (long long i = 1; i <= n; i++) bestp[i] = max(bestp[i - 1], best[i]);
  for (long long i = n; i >= 1; i--) best[i] = max(best[i], best[i + 1]);
  if (k == 0) {
    cout << best[1];
  } else if (k == 1) {
    long long ans = max(sum[1] - a[2] - d[1], best[2] + max(0LL, a[1] - d[1]));
    for (long long i = 2; i <= n - 1; i++) {
      ans = max(ans, max(0LL, sum[1] - sum[i + 1] - mn[i]) + best[i + 1]);
      if (i < n - 1) {
        ans = max(ans, bestp[i] - a[i + 1]);
      }
    }
    cout << ans;
  } else {
    cout << max(0LL, max(a[n] - d[n], sum[1] - mn[n - 1]));
  }
}
