#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int v[n];
  for (int i = 0; i < n; i++) cin >> v[i];
  long long ans = 0;
  long long temp;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp == 1) {
      p[i] = 0;
      ans += v[i];
    } else
      p[i] = v[i];
    if (i == 0) continue;
    p[i] += p[i - 1];
  }
  temp = p[k - 1];
  for (int i = k; i < n; i++)
    if (p[i] - p[i - k] > temp) temp = p[i] - p[i - k];
  cout << temp + ans;
  return 0;
}
