#include <bits/stdc++.h>
using namespace std;
const int dirnd[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int dirrd[6][3] = {{0, 0, 1},  {0, 0, -1}, {1, 0, 0},
                         {-1, 0, 0}, {0, 1, 0},  {0, -1, 0}};
const int MAX = 1e5 + 10;
const int N = 65535;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
inline long long in() {
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  long long x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
int a[MAX];
bool b[MAX];
int c[MAX];
int main() {
  int n = in(), k = in();
  int ans = 0;
  for (int i = 0; i < n; i++) a[i] = in();
  for (int i = 0; i < n; i++) {
    b[i] = in();
    if (b[i]) ans += a[i];
  }
  for (int i = 1; i <= n; i++) {
    c[i] = c[i - 1];
    if (!b[i - 1]) c[i] += a[i - 1];
  }
  int Max = 0;
  for (int i = k; i <= n; i++) {
    int t = c[i] - c[i - k];
    Max = max(t, Max);
  }
  printf("%d\n", Max + ans);
  return 0;
}
