#include <bits/stdc++.h>
using namespace std;
long long int a[1000005];
long long int b[1000005];
long long int pre[1000005];
long long int suff[1000005];
int main() {
  long long int n, k;
  scanf("%lld%lld", &n, &k);
  for (long long int i = 1; i <= n; i++) scanf("%lld", a + i);
  for (long long int i = 1; i <= n; i++) scanf("%lld", b + i);
  for (long long int i = 1; i <= n; i++) {
    if (b[i]) {
      pre[i] = a[i];
      suff[i] = a[i];
    }
  }
  for (long long int i = 1; i <= n; i++) a[i] += a[i - 1];
  for (long long int i = 1; i <= n; i++) pre[i] += pre[i - 1];
  for (long long int i = n; i > 0; i--) suff[i] += suff[i + 1];
  long long int ans = 0;
  for (long long int i = k; i <= n; i++)
    ans = max(ans, a[i] - a[i - k] + pre[i - k] + suff[i + 1]);
  printf("%lld\n", ans);
  return 0;
}
