#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(1 + n), d(1 + n);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> d[i];
  if (k == 0) {
    long long best = 0, curSuffix = 0;
    for (int i = n; i >= 1; --i) {
      curSuffix += a[i];
      best = max(best, curSuffix - d[i]);
    }
    cout << best << endl;
  } else if (k == 1) {
    long long best = 0;
    best = max(best, accumulate(a.begin() + 1, a.end(), 0LL) -
                         *min_element(a.begin() + 2, a.end() - 1) - d[1]);
    vector<long long> suffixBest(1 + n);
    suffixBest[n] = max(0, a[n] - d[n]);
    long long total = a[n];
    for (int i = n - 1; i >= 1; --i) {
      total += a[i];
      suffixBest[i] = max(total - d[i], suffixBest[i + 1]);
    }
    best = max(best, suffixBest[2] + max(0, a[1] - d[1]));
    int cheapest = d[1];
    total = a[1];
    for (int i = 2; i < n; ++i) {
      cheapest = min(cheapest, d[i]);
      total += a[i];
      long long cur = total - cheapest;
      cur = max(cur, 0LL);
      cur += suffixBest[i + 1];
      best = max(best, cur);
    }
    cout << best << endl;
  } else {
    long long best = max(0, a[n] - d[n]);
    best = max(best, accumulate(a.begin() + 1, a.end(), 0LL) -
                         *min_element(d.begin() + 1, d.end() - 1));
    cout << best << endl;
  }
  return 0;
}
