#include <bits/stdc++.h>
using namespace std;
const long long LINF = 4557430888798830399LL;
const long long MAXN = 1000000;
long long n, k;
long long sum[MAXN + 5];
pair<long long, long long> isi[MAXN + 5];
long long check0() {
  long long ans = 0;
  for (int i = n; i >= 1; i--) ans = max(ans, sum[i] - isi[i].second);
  return ans;
}
long long check1a() {
  long long ans = LINF;
  for (int i = 1; i < n; i++) ans = min(ans, isi[i].second);
  ans = (sum[1] - isi[n].first) - ans;
  long long profit = max(0LL, isi[n].first - isi[n].second);
  return max(ans + profit, profit);
}
long long check1b() {
  pair<long long, long long> maksi = {LINF, LINF};
  for (int i = 1; i < n; i++) {
    if (isi[i].second <= maksi.first) {
      maksi.second = maksi.first;
      maksi.first = isi[i].second;
    } else if (isi[i].second <= maksi.second) {
      maksi.second = isi[i].second;
    }
  }
  return sum[1] - (maksi.first + maksi.second);
}
long long check1c() {
  long long ans = 0;
  for (int i = n; i >= 2; i--) ans = max(ans, sum[i] - isi[i].second);
  long long mini = LINF;
  for (int i = 2; i < n; i++) mini = min(mini, isi[i].first);
  return max(ans, sum[1] - mini - isi[1].second);
}
long long check2() {
  long long ans = LINF;
  for (int i = 1; i < n; i++) ans = min(ans, isi[i].second);
  return max(isi[n].first - isi[n].second, sum[1] - ans);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> isi[i].first;
  for (int i = 1; i <= n; i++) cin >> isi[i].second;
  for (int i = n; i >= 1; i--) sum[i] = isi[i].first + sum[i + 1];
  long long ans = 0;
  if (k == 0)
    ans = max(ans, check0());
  else if (k == 1)
    ans = max(ans, max(check1c(), max(check1a(), check1b())));
  else
    ans = max(ans, check2());
  cout << ans << endl;
  return 0;
}
