#include <bits/stdc++.h>
int n, k, a[100001], is[100001], i, j, sum, ans;
int main() {
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &is[i]);
  for (i = 0; i < k; i++) sum += a[i];
  for (i = k; i < n; i++)
    if (is[i]) sum += a[i];
  ans = sum;
  for (i = 0; i < n - k + 1; i++) {
    if (is[i] == 0) sum -= a[i];
    if (is[i + k] == 0) sum += a[i + k];
    if (ans < sum) ans = sum;
  }
  printf("%d", ans);
}
