#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> v, t;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  int somf = 0, somt = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    t.push_back(x);
    if (i < k) somf += v[i];
    if (i >= k && t[i] == 1) somt += v[i];
  }
  somf += somt;
  int final = somf, idx = k - 1;
  somf -= somt;
  for (int i = k; i < n; i++) {
    if (t[i - k] == 0) somf -= v[i - k];
    if (t[i] == 1) somt -= v[i];
    somf += v[i] + somt;
    if (somf > final) {
      idx = i;
      final = somf;
    }
    somf -= somt;
  }
  if (somf > final) {
    idx = n - 1;
    final = somf;
  }
  cout << final << endl;
}
