#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> lec(n);
  vector<int> awake(n);
  for (int i = 0; i < n; i++) {
    cin >> lec[i];
  }
  int maxm = 0;
  for (int i = 0; i < n; i++) {
    cin >> awake[i];
    if (awake[i] == 1) {
      maxm = maxm + lec[i];
    }
  }
  for (int i = 0; i < k; i++) {
    if (awake[i] == 0) {
      maxm = maxm + lec[i];
    }
  }
  int tsum = maxm;
  for (int i = k; i < n; i++) {
    int add = 0, sub = 0;
    if (awake[i] == 0) add = lec[i];
    if (awake[i - k] == 0) sub = lec[i - k];
    add = add - sub;
    tsum = tsum + add;
    maxm = max(maxm, tsum);
  }
  cout << maxm << endl;
}
