#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};
int n, k;
vector<int> vec, vec2;
int aa[100005];
int bb[100005];
unsigned long long int ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vec.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vec2.push_back(a);
  }
  if (vec2[0] == 1) aa[0] = vec[0];
  if (vec2[0] == 0) bb[0] = vec[0];
  for (int i = 1; i < int(vec.size()); i++) {
    if (vec2[i] == 1)
      aa[i] = aa[i - 1] + vec[i];
    else
      aa[i] = aa[i - 1];
    if (vec2[i] == 0)
      bb[i] = bb[i - 1] + vec[i];
    else
      bb[i] = bb[i - 1];
  }
  for (int i = 0; i < int(vec.size()); i++)
    if (vec2[i] == 1) ans += vec[i];
  int a = 0, b = k - 1;
  unsigned long long int aux = ans;
  while (a < int(vec.size())) {
    while (b < int(vec.size()) and b < a + k) {
      aux = max(aux, ans + (bb[b] - bb[b - k]));
      b++;
    }
    a++;
  }
  cout << aux << "\n";
  return 0;
}
