#include <bits/stdc++.h>
using namespace std;
int dX1[4] = {0, 0, -1, 1};
int dY1[4] = {-1, 1, 0, 0};
int dX2[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dY2[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int mxn = 100000;
int a[mxn], d[mxn];
int N, K;
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  long long ans = 0;
  long long cur = 0;
  long long mii = 1e9;
  if (K == 0) {
    for (int i = N - 1; i >= 0; i--) {
      cur += a[i];
      ans = max(ans, cur - d[i]);
    }
    cout << ans << '\n';
  } else if (K == 1) {
    vector<long long> suffix(N + 1, 0);
    for (int i = N - 1; i >= 0; i--) {
      cur += a[i];
      suffix[i] = max(suffix[i + 1], cur - d[i]);
      if (i > 0) {
        ans = max(ans, suffix[i]);
      }
    }
    cur = 0;
    for (int i = 0; i + 1 < N; i++) {
      cur += a[i];
      mii = min(mii, 0LL + d[i]);
      ans = max(ans, cur - mii + suffix[i + 1]);
    }
    cur += a[N - 1];
    for (int i = 1; i < N; i++) {
      ans = max(ans, cur - d[0] - a[i]);
    }
    cout << ans << '\n';
  } else {
    for (int i = 0; i < N; i++) {
      ans += a[i];
    }
    for (int i = 0; i + 1 < N; i++) {
      mii = min(mii, 0LL + d[i]);
    }
    cout << max(0LL + a[N - 1] - d[N - 1], max(0LL, ans - mii)) << '\n';
  }
}
