#include <bits/stdc++.h>
using namespace std;
int n, k, a[100010], t, sum1[100010], sum[100010], ma;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum1[i] = sum1[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    if (t == 1)
      sum[i] = sum[i - 1] + a[i];
    else
      sum[i] = sum[i - 1];
  }
  for (int i = 1; i + k - 1 <= n; i++) {
    ma = max(ma, sum[n] - sum[i + k - 1] + sum[i - 1] + sum1[i + k - 1] -
                     sum1[i - 1]);
  }
  printf("%d\n", ma);
  return 0;
}
