#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, p1 = 0;
  long long s1 = 0, s2 = 0, s = 0, max = 0, p2 = 0;
  cin >> n >> k;
  int ar[n];
  int pre[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  int ar1[n];
  for (int i = 0; i < n; i++) cin >> ar1[i];
  pre[0] = ar[0];
  int pre2[n];
  if (ar1[0] == 1)
    pre2[0] = ar[0];
  else
    pre2[0] = 0;
  for (int i = 1; i < n; i++) pre[i] = pre[i - 1] + ar[i];
  for (int i = 1; i < n; i++) {
    if (ar1[i] == 1)
      pre2[i] = pre2[i - 1] + ar[i];
    else
      pre2[i] = pre2[i - 1];
  }
  for (int i = 0; i <= (n - k); i++) {
    if (i != 0) {
      s = pre[i + k - 1] - pre[i - 1];
      s1 = pre2[i + k - 1] - pre2[i - 1];
    } else {
      s = pre[i + k - 1];
      s1 = pre2[i + k - 1];
    }
    s2 = s - s1;
    if (s2 > max) {
      max = s2;
      p1 = i;
    }
  }
  for (int i = p1; i < (p1 + k); i++) {
    ar1[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (ar1[i] == 1) p2 = p2 + ar[i];
  }
  cout << p2 << endl;
  return 0;
}
