#include <bits/stdc++.h>
using namespace std;
long long a[100003], d[100003], kum[100003];
int main() {
  int n, k;
  cin >> n >> k;
  long long mina = 1e7;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    kum[i] = kum[i - 1] + a[i];
    if (i == 1) continue;
    mina = min(a[i], mina);
  }
  long long min1 = 1e7, min2 = 1e7;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (i == n) break;
    if (d[i] < min1) {
      min2 = min1;
      min1 = d[i];
    } else if (d[i] < min2)
      min2 = d[i];
  }
  if (k == 0) {
    long long sol = 0ll;
    for (int i = 1; i <= n; i++) {
      sol = max(kum[n] - kum[i - 1] - d[i], sol);
    }
    cout << max(0ll, sol);
    return 0;
  }
  if (k == 1) {
    long long m = min(min(min1 + min2, mina + d[1]), min1 + min(a[n], d[n]));
    long long sol = 0ll;
    for (int i = 2; i <= n; i++) {
      sol = max(kum[n] - kum[i - 1] - d[i], sol);
    }
    cout << max(max(sol, 0ll), kum[n] - m);
    return 0;
  }
  cout << max(0ll, max(kum[n] - min1, a[n] - d[n]));
  return 0;
}
