#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1e18;
const long long mod = 1e9 + 7;
const int maxn = 3e6;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(n), d(n);
  long long minD = INF64;
  long long sumA = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sumA += a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  for (int i = 0; i < n - 1; i++) {
    minD = min(minD, d[i]);
  }
  if (k == 0) {
    long long sumSuf = sumA;
    long long maxAns = 0;
    for (int i = 0; i < n; i++) {
      maxAns = max(maxAns, sumSuf - d[i]);
      sumSuf -= a[i];
    }
    cout << maxAns;
    return;
  }
  if (k == 1) {
    long long sumSuf = sumA - a[0];
    long long maxAns1 = 0;
    for (int i = 1; i < n; i++) {
      maxAns1 = max(maxAns1, sumSuf - d[i]);
      sumSuf -= a[i];
    }
    long long maxAns2 = 0;
    long long prefMinD = INF64;
    long long prefSumA = 0;
    for (int i = 0; i < n - 1; i++) {
      prefSumA += a[i];
      prefMinD = min(prefMinD, d[i]);
      long long sum1 = prefSumA - prefMinD;
      long long sum2 = (sumA - prefSumA) - d[i + 1];
      maxAns2 = max(maxAns2, max(sum1, 0ll) + max(sum2, 0ll));
    }
    long long maxAns3 = 0;
    for (int i = 1; i < n - 1; i++) {
      long long sum1 = (sumA - a[i]) - d[0];
      long long sum2 = a[i] - d[i];
      maxAns3 = max(maxAns3, max(sum1, 0ll) + max(sum2, 0ll));
    }
    long long maxAns = max(maxAns1, max(maxAns2, maxAns3));
    cout << maxAns;
    return;
  }
  cout << max(max(sumA - minD, a.back() - d.back()), 0ll);
}
int main(int argc, char** argv) {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
