#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2, INF = 0x3f3f3f3f;
long long int pre[N], nxt[N], bac[N];
int n, k, a[N], d[N], c[N];
inline void cmax(long long int& x, long long int y) {
  if (x - y >> 63) x = y;
}
inline void input() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) scanf("%d", d + i);
}
struct node {
  long long int sum, val;
  node operator+(const node& u) const {
    return (node){sum + u.sum, max(u.val, val + u.sum)};
  }
} pro[N], suf[N], t[N];
inline void init() {
  c[0] = INF;
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];
  for (int i = n; i >= 1; i--) nxt[i] = nxt[i + 1] + a[i];
  for (int i = 1; i <= n; i++) c[i] = min(c[i - 1], d[i]);
  for (int i = 1; i <= n; i++) t[i] = (node){a[i], a[i] - d[i]};
  pro[0] = (node){0, -INF};
  for (int i = 1; i <= n; i++) pro[i] = pro[i - 1] + t[i];
  for (int i = n; i >= 1; i--) suf[i] = t[i] + suf[i + 1];
}
long long int ask0(long long int out = 0) {
  for (int i = 1; i <= n; i++) cmax(out, nxt[i] - d[i]);
  return out;
}
long long int ask1(long long int out = 0) {
  for (int i = 2; i <= n - 1; i++)
    cmax(out, max(0ll, pre[i] - c[i]) + max(nxt[i + 1] - d[i + 1], 0ll));
  for (int i = 2; i <= n - 1; i++)
    cmax(out, (pro[i - 1] + suf[i + 1]).val + max(0, a[i] - d[i]));
  for (int i = 2; i <= n; i++) cmax(out, nxt[i] - d[i]);
  return out;
}
inline void work() {
  if (k == 0) return void(cout << ask0());
  if (k == 1) return void(cout << ask1());
  cout << max(max(0ll, pre[n] - c[n - 1]), 0ll + a[n] - d[n]);
}
int main() {
  input();
  init();
  work();
  return 0;
}
