#include <bits/stdc++.h>
int take() {
  int n;
  scanf("%d", &n);
  return n;
}
double ttake() {
  double n;
  scanf("%lf", &n);
  return n;
}
long long takes() {
  long long n;
  scanf("%lld", &n);
  return n;
}
int cas;
using namespace std;
bool approximatelyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool essentiallyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyGreaterThan(float a, float b, float epsilon) {
  return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyLessThan(float a, float b, float epsilon) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
long long pre[200005], suff[200005], tot[200005];
int main() {
  int n = take(), k = take(), arr[n + 1], up[n + 1];
  for (int i = 1; i <= n; i += 1) arr[i] = take();
  for (int i = 1; i <= n; i += 1) up[i] = take();
  for (int i = 1; i <= n; i += 1) {
    tot[i] += tot[i - 1] + arr[i];
    pre[i] = pre[i - 1] + up[i] * arr[i];
  }
  for (int i = n; i >= 1; i--) {
    suff[i] = suff[i + 1] + up[i] * arr[i];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i += 1) {
    int d = i + k;
    if (d > n) d = n + 1;
    ans = max(ans, pre[i - 1] + suff[d] + tot[d - 1] - tot[i - 1]);
  }
  printf("%lld\n", ans);
  { return 0; };
}
