#include <bits/stdc++.h>
int main() {
  int y, i, j, k, n, a = 0, b = 0, max, s[100050], x[100050];
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &s[i]);
  for (j = 0; j < n; j++) scanf("%d", &x[j]);
  for (i = 0; i < n; i++) {
    if (x[i] == 1) {
      a += s[i];
    }
  }
  for (i = 0; i < k; i++) {
    if (x[i] == 0) b = b + s[i];
  }
  max = b;
  for (i = 1; i < n; i++) {
    if (x[i - 1] == 0) b = b - s[i - 1];
    if (x[i + k - 1] == 0 && i + k - 1 < n) b = b + s[i + k - 1];
    if (max < b) max = b;
  }
  printf("%d\n", a + max);
  return 0;
}
