#include <bits/stdc++.h>
using namespace std;
int n, k;
int lectures[100000];
int awake[100000];
int indexFrom, indexTo, bestIndexFrom, bestIndexTo, value, bestValue;
int main() {
  cin >> n >> k;
  indexFrom = 0;
  indexTo = k;
  value = 0;
  bestValue = 0;
  for (int i = 0; i < n; i++) {
    cin >> lectures[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> awake[i];
  }
  for (int i = indexFrom; i < indexTo; i++) {
    if (!awake[i]) value += lectures[i];
  }
  bestValue = value;
  bestIndexTo = indexTo;
  bestIndexFrom = indexFrom;
  while (indexTo < n) {
    if (!awake[indexFrom]) value -= lectures[indexFrom];
    if (!awake[indexTo]) value += lectures[indexTo];
    indexFrom++;
    indexTo++;
    if (value > bestValue) {
      bestValue = value;
      bestIndexFrom = indexFrom;
      bestIndexTo = indexTo;
    }
  }
  for (int i = 0; i < n; i++) {
    if (awake[i]) bestValue += lectures[i];
  }
  cout << bestValue << endl;
}
