#include <bits/stdc++.h>
using namespace std;
const unsigned int INF = 1 << 30;
const int mod = 1e9 + 7;
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int a[110000];
  int sign[110000];
  int sum1[110000];
  int sum2[110000];
  int ans = 0;
  sum1[0] = sum2[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum1[i] = sum1[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &sign[i]);
    if (sign[i]) {
      ans += a[i];
      sum2[i] = sum2[i - 1] + a[i];
    } else
      sum2[i] = sum2[i - 1];
  }
  int mmax = 0;
  for (int i = 1; i <= n - k + 1; i++) {
    int sum = (sum1[i + k - 1] - sum1[i - 1]) - (sum2[i + k - 1] - sum2[i - 1]);
    if (sum > mmax) mmax = sum;
  }
  ans += mmax;
  cout << ans << endl;
  return 0;
}
