#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long a[100005], d[100005];
long long sum[100005], lmin[100005];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (long long(i) = (1); (i) <= (n); (i)++) cin >> a[i];
  for (long long(i) = (1); (i) <= (n); (i)++) cin >> d[i];
  lmin[0] = 1e18;
  for (long long(i) = (1); (i) <= (n); (i)++) {
    sum[i] = sum[i - 1] + a[i];
    lmin[i] = min(lmin[i - 1], d[i]);
  }
  long long ans = 0;
  if (k == 0) {
    for (long long(i) = (1); (i) <= (n); (i)++)
      (ans) = max((ans), ((sum[n] - sum[i - 1]) - d[i]));
  }
  if (k == 1) {
    for (long long(i) = (2); (i) <= (n - 1); (i)++)
      (ans) = max((ans), (max(0LL, sum[i] - lmin[i]) +
                          max(0LL, (sum[n] - sum[i]) - d[i + 1])));
    for (long long(i) = (2); (i) <= (n - 1); (i)++)
      (ans) = max((ans), (sum[n] - d[1] - d[i]));
    for (long long(i) = (2); (i) <= (n - 1); (i)++)
      (ans) = max((ans), (sum[n] - a[i] - d[1]));
    (ans) = max((ans), (sum[n] - a[2] - d[1]));
    (ans) = max((ans), (sum[n] - a[1] - d[2]));
  }
  if (k >= 2) {
    (ans) = max((ans), (a[n] - d[n]));
    (ans) = max((ans), (sum[n] - lmin[n - 1]));
  }
  cout << ans << endl;
  return 0;
}
