#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long a[200000], pre[200000], c[200000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  pre[n - 1] = a[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    pre[i] = pre[i + 1] + a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
  }
  long long ans = 0;
  if (k == 0) {
    for (long long i = 0; i < n; i++) {
      ans = max(ans, pre[i] - c[i]);
    }
    cout << ans << endl;
  } else if (k >= 2) {
    long long m = INT_MAX;
    for (long long i = 0; i < n - 1; i++) {
      m = min(m, c[i]);
    }
    cout << max({ans, pre[0] - m, a[n - 1] - c[n - 1], a[0] + a[n - 1] - c[0]})
         << endl;
  } else {
    long long m = INT_MAX, p = INT_MAX;
    for (long long i = 0; i < n - 1; i++) {
      m = min(m, c[i]);
    }
    ans = max({ans, pre[0] - a[n - 1] - m,
               pre[0] - a[n - 1] - m + a[n - 1] - c[n - 1]});
    m = INT_MAX;
    for (int i = 0; i < n - 1; i++) {
      if (c[i] <= m) {
        p = m;
        m = c[i];
      } else if (c[i] <= p) {
        p = c[i];
      }
    }
    ans = max(ans, pre[0] - (m + p));
    m = 0;
    for (int i = 1; i < n; i++) {
      m = max(m, pre[i] - c[i]);
    }
    p = INT_MAX;
    for (int i = 1; i < n - 1; i++) {
      p = min(p, a[i]);
    }
    ans = max({ans, m, pre[0] - p - c[0]});
    cout << ans << endl;
  }
  return 0;
}
