#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> T(N);
  for (int& a : A) cin >> a;
  for (int& t : T) cin >> t;
  vector<int64_t> pref(N);
  vector<int64_t> suf(N);
  for (int i = 0; i < N; i++) {
    int v = A[i] * T[i];
    if (i > 0)
      pref[i] = pref[i - 1] + v;
    else
      pref[i] = v;
  }
  for (int i = N - 1; i >= 0; i--) {
    int v = A[i] * T[i];
    if (i == N - 1)
      suf[i] = v;
    else
      suf[i] = suf[i + 1] + v;
  }
  vector<int64_t> p(N);
  int64_t r = 0;
  for (int i = 0; i < N; i++) {
    r += A[i];
    p[i] = r;
  }
  int64_t ans = 0;
  for (int i = 0; i + K - 1 < N; i++) {
    int64_t cur = 0;
    if (i + K < N) cur += suf[i + K];
    if (i > 0) cur += pref[i - 1];
    int64_t range_sum = p[i + K - 1];
    if (i > 0) range_sum -= p[i - 1];
    cur += range_sum;
    ans = max(ans, cur);
  }
  cout << ans << '\n';
  return 0;
}
