#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> gain(n), cost(n);
  for (auto& i : gain) cin >> i;
  for (auto& i : cost) cin >> i;
  vector<ll> tot(n);
  tot[n - 1] = gain[n - 1];
  for (int i = n - 2; i >= 0; i--) tot[i] = tot[i + 1] + gain[i];
  ll ans = max(0, gain[n - 1] - cost[n - 1]);
  if (k == 0) {
    for (int i = n - 2; i >= 0; i--) ans = max(ans, tot[i] - cost[i]);
  } else if (k == 1) {
    for (int i = n - 2; i >= 1; i--) ans = max(ans, tot[i] - cost[i]);
    ans = max(ans, tot[0] - gain[1] - cost[0]);
    int tt = *min_element(cost.begin(), cost.end() - 1);
    ans = max(ans, tot[0] - gain[n - 1] - tt);
    tt = *min_element(gain.begin(), gain.end());
    ans = max(ans, tot[0] - tt - cost[0]);
    sort(cost.begin(), cost.end());
    ans = max(ans, tot[0] - cost[0] - cost[1]);
  } else if (k >= 2) {
    int tt = *min_element(cost.begin(), cost.end() - 1);
    ans = max(ans, tot[0] - tt);
  }
  cout << ans;
}
