#include <bits/stdc++.h>
using namespace std;
int n, k;
int thm[200005];
int stat[200005];
int main() {
  cin >> n >> k;
  for (int i = 0; i < (n); i++) cin >> thm[i];
  for (int i = 0; i < (n); i++) cin >> stat[i];
  long long init = inner_product(thm, thm + n, stat, 0), ans;
  for (int i = 0; i < k; i++) {
    if (stat[i] == 0) init += thm[i];
  }
  ans = init;
  for (int l = 0, r = k; r < n; r++, l++) {
    if (stat[l] == 0) init -= thm[l];
    if (stat[r] == 0) init += thm[r];
    ans = max(ans, init);
  }
  cout << ans << endl;
  return 0;
}
