#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
int tree[2][mx];
int arr[mx + 5];
int main() {
  int i, j, k, n, m, p, q;
  scanf("%d %d", &n, &k);
  int a[n + 5];
  for (i = 1; i <= n; i++) {
    scanf("%d", arr + i);
    tree[0][i] = tree[0][i - 1] + arr[i];
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &p);
    if (p) {
      tree[1][i] = tree[1][i - 1] + arr[i];
    } else {
      tree[1][i] = tree[1][i - 1];
    }
  }
  int ans = 0, part, tot;
  for (i = 1; i <= n; i++) {
    m = min(i + k - 1, n);
    tot = 0;
    tot += tree[1][i - 1];
    tot += tree[1][n] - tree[1][m];
    tot += tree[0][m] - tree[0][i - 1];
    ans = max(ans, tot);
  }
  return !printf("%d\n", ans);
}
