#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, sum = 0;
  cin >> n >> k;
  int arr1[n], arr2[n];
  for (int i = 0; i < n; ++i) cin >> arr1[i];
  for (int i = 0; i < n; ++i) {
    cin >> arr2[i];
    if (arr2[i] == 1) sum += arr1[i];
  }
  int res = 0, res1 = 0, res2 = 0;
  for (int i = 0; i < k; ++i) {
    res += arr1[i];
    if (arr2[i] == 0) res1 += arr1[i];
  }
  res2 = res1;
  int cur_sum = res;
  for (int i = k; i < n; ++i) {
    cur_sum += (arr1[i] - arr1[i - k]);
    res = max(cur_sum, res);
    if (arr2[i] == 0) res2 += arr1[i];
    if (arr2[i - k] == 0) res2 -= arr1[i - k];
    res1 = max(res1, res2);
  }
  cout << res1 + sum << endl;
  return 0;
}
