#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
long long val[maxn];
int main() {
  int k, n;
  scanf("%d%d", &n, &k);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &val[i]);
  }
  for (int i = 0; i < n; i++) {
    int wak;
    scanf("%d", &wak);
    if (wak) {
      ans += val[i];
      val[i] = 0;
    }
  }
  int beg = 0;
  int end = min(n - 1, k - 1);
  long long temp = 0;
  long long ma;
  for (int i = 0; i <= end; i++) temp += val[i];
  ma = temp;
  while (end + 1 < n) {
    temp -= val[beg];
    temp += val[end + 1];
    ma = max(ma, temp);
    end++;
    beg++;
  }
  printf("%lld\n", ans + ma);
  return 0;
}
