#include <bits/stdc++.h>
using namespace std;
int N, K, ans, x;
int arr[100001], prefix[100001];
int main() {
  scanf("%d %d", &N, &K);
  ans = 0;
  for (int i = 1; i <= N; i++) scanf("%d", &arr[i]);
  scanf("%d", &x);
  prefix[0] = 0;
  if (x == 1) {
    ans += arr[1];
    arr[1] = 0;
  }
  prefix[1] = arr[1];
  for (int i = 2; i <= N; i++) {
    scanf("%d", &x);
    if (x == 1) {
      ans += arr[i];
      arr[i] = 0;
    }
    prefix[i] = arr[i] + prefix[i - 1];
  }
  int MAX = 0;
  for (int i = 1; i <= N - K + 1; i++)
    MAX = max(MAX, prefix[i + K - 1] - prefix[i - 1]);
  printf("%d\n", ans + MAX);
}
