#include <bits/stdc++.h>
using namespace std;
long long int ara[100005];
long long int csum[100005];
int main() {
  long long int n, k;
  cin >> n >> k;
  for (long long int i = 0; i < n; ++i) {
    cin >> ara[i];
  }
  long long int x;
  long long int s = 0;
  for (long long int i = 1; i <= n; ++i) {
    cin >> x;
    if (!x)
      csum[i] += ara[i - 1];
    else
      s += ara[i - 1];
    csum[i] += csum[i - 1];
  }
  long long int mx = csum[k];
  for (long long int i = k; i <= n; ++i) {
    mx = max(mx, csum[i] - csum[i - k]);
  }
  cout << mx + s << "\n";
}
