#include <bits/stdc++.h>
using namespace std;
bool isrange(int second, int first, int n, int m) {
  if (0 <= second && second < n && 0 <= first && first < m) return true;
  return false;
}
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1},
    ddy[8] = {1, 0, -1, 0, 1, 1, -1, -1}, ddx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MAX = 101010;
long long int val1[MAX], val2[MAX], dp[MAX];
int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int e = 1; e <= n; e++) scanf("%lld", &val1[e]);
  for (int e = 1; e <= n; e++) scanf("%lld", &val2[e]);
  long long int ans = max((long long int)0, val1[n] - val2[n]);
  if (k == 0) {
    long long int tot = 0;
    for (int e = n; e >= 1; e--) {
      tot += val1[e];
      ans = max(ans, tot - val2[e]);
    }
    printf("%lld\n", ans);
  } else if (k % 2 == 0) {
    long long int tot = 0;
    for (int e = 1; e <= n; e++) tot += val1[e];
    long long int mm = 1e9;
    for (int e = 1; e < n; e++) mm = min(mm, val2[e]);
    tot -= mm;
    printf("%lld", max(ans, tot));
  } else if (k == 1) {
    long long int tot = 0;
    long long int mm = 1e9;
    for (int e = n; e >= 1; e--) {
      tot += val1[e];
      dp[e] = max(dp[e + 1], tot - val2[e]);
    }
    tot = 0;
    for (int e = 1; e < n; e++) {
      tot += val1[e];
      mm = min(mm, val2[e]);
      ans = max(ans, max((long long int)0, tot - mm) + dp[e + 1]);
    }
    tot = val1[n];
    mm = 1e9;
    for (int e = n - 1; e >= 1; e--) {
      tot += val1[e];
      if (e <= n - 2) {
        ans = max(ans, tot - mm - val2[e]);
      }
      if (val1[e] > val2[e])
        mm = min(mm, val2[e]);
      else
        mm = min(mm, val1[e]);
    }
    printf("%lld", ans);
  } else {
    long long int tot = 0;
    long long int mm = 1e9;
    for (int e = 1; e <= n; e++) tot += val1[e];
    for (int e = 1; e < n; e++) mm = min(mm, val2[e]);
    tot -= mm;
    printf("%lld", max(ans, tot));
  }
  return 0;
}
