#include <bits/stdc++.h>
using namespace std;
int N, k;
long long A[100005], D[100005];
long long sum[100005];
long long sumf[100005];
long long MIN[100005];
long long MAX[100005];
int main(void) {
  cin >> N >> k;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N; i++) cin >> D[i];
  sum[N] = A[N] - D[N];
  MAX[N] = A[N] - D[N];
  long long ans = 0;
  for (int i = N - 1; i > 0; i--) {
    sum[i] = sum[i + 1] + D[i + 1] + A[i] - D[i];
    MAX[i] = max(MAX[i + 1], sum[i]);
  }
  sumf[1] = A[1];
  for (int i = 2; i <= N; i++) sumf[i] = sumf[i - 1] + A[i];
  MIN[1] = D[1];
  for (int i = 2; i <= N; i++) MIN[i] = min(D[i], MIN[i - 1]);
  if (k == 0) {
    for (int i = 1; i <= N; i++) ans = max(ans, sum[i]);
    cout << ans << endl;
  } else if (k == 1) {
    long long temp1 = 0;
    for (int i = 2; i < N; i++) {
      long long count = sumf[i] - MIN[i];
      if (count <= 0) count = 0;
      long long sum1 = MAX[i + 1];
      if (sum1 > 0) count += sum1;
      temp1 = max(count, temp1);
    }
    long long temp2 = 0;
    for (int i = 2; i <= N; i++) temp2 = max(temp2, sum[i]);
    long long temp3 = 0;
    int minn = 2;
    for (int i = 2; i < N; i++)
      if (A[i] < A[minn]) minn = i;
    for (int i = 1; i <= N; i++)
      if (i == minn) {
        if (A[i] - D[i] > 0) temp3 += A[i] - D[i];
      } else
        temp3 += A[i];
    temp3 -= D[1];
    ans = max(temp1, temp2);
    ans = max(ans, temp3);
    cout << ans << endl;
  } else {
    int min = 1;
    for (int i = 1; i < N; i++) {
      ans += A[i];
      if (D[i] < D[min]) min = i;
    }
    ans -= D[min];
    ans += A[N];
    ans = max(max((long long)0, A[N] - D[N]), ans);
    cout << ans << endl;
  }
  return 0;
}
