#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  long long cou;
  cou = 1;
  for (long long coui = (0); coui < (cou); coui++) {
    long long n, k;
    cin >> n >> k;
    vector<long long> vals(n);
    vector<long long> costs(n);
    for (long long i = (0); i < (n); i++) cin >> vals[i];
    for (long long i = (0); i < (n); i++) cin >> costs[i];
    long long sum = 0;
    long long best = 0;
    for (long long i = (n)-1; i >= (0); i--) {
      sum += vals[i];
      if (k != 1 || i > 0) best = max(best, sum - costs[i]);
    }
    long long minimal = 100000000;
    for (long long i = (0); i < (n - 1); i++) minimal = min(minimal, costs[i]);
    if (k > 0) {
      best = max(best, sum - vals[n - 1] - minimal);
      best = max(best, sum - costs[n - 1] - minimal);
      for (long long i = (0); i < (n - 1); i++) {
        best = max(best, sum - costs[i] - costs[i + 1]);
      }
      for (long long i = (0); i < (n); i++) {
        best = max(best, sum - costs[0] - vals[i]);
      }
    }
    if (k > 1) {
      best = max(best, sum - minimal);
    }
    cout << best << "\n";
  }
  return 0;
}
