#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int k, n;
  cin >> n >> k;
  int val[100000];
  int awake[100000];
  for (int i = 0; i < n; ++i) {
    cin >> val[i];
  }
  int sum = 0;
  int extra = 0;
  int max = 0;
  for (int i = 0; i < n; ++i) {
    cin >> awake[i];
    if (awake[i]) {
      sum += val[i];
      val[i] = 0;
    }
    if (i < k) {
      extra += val[i];
    } else {
      extra = extra + val[i] - val[i - k];
    }
    if (extra > max) {
      max = extra;
    }
  }
  sum += max;
  cout << sum << endl;
  return 0;
}
