#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000000 + 7;
const long long int N = 10000000 + 6;
const double pi = acos(-1);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n], b[n], sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i] == 1) sum += a[i];
  }
  int x = 0, y = k - 1, magicsum = 0;
  for (int i = x; i <= y; i++) {
    if (b[i] == 0) magicsum += a[i];
  }
  int max = magicsum;
  while (y != n) {
    if (b[x] == 0) magicsum -= a[x];
    x++;
    y++;
    if (b[y] == 0) magicsum += a[y];
    if (magicsum > max) max = magicsum;
  }
  cout << sum + max;
  return 0;
}
