#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int theory[n];
  for (int i = 0; i < n; i++) {
    cin >> theory[i];
  }
  int awake[n];
  long long int actual = 0;
  for (int i = 0; i < n; i++) {
    cin >> awake[i];
    actual += theory[i] * awake[i];
  }
  int index = 0;
  long long int maxpd, subtc = 0;
  long long int pd = 0;
  for (int i = 0; i < k; i++) {
    pd += theory[i];
    subtc += theory[i] * awake[i];
  }
  maxpd = actual - subtc + pd;
  long long int dem;
  for (int i = 1; i < n - k + 1; i++) {
    pd = pd - theory[i - 1] + theory[i + k - 1];
    subtc = subtc - theory[i - 1] * awake[i - 1] +
            theory[i + k - 1] * awake[i + k - 1];
    dem = actual - subtc + pd;
    if (dem > maxpd) {
      maxpd = dem;
      index = i;
    }
  }
  cout << maxpd;
  return 0;
}
