#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, k;
int a[N], p[N], ans;
void solve() {
  int l = 1, r = 1;
  int maxx = 0;
  while (l <= n) {
    while (r <= n && r - l + 1 <= k) {
      if (!p[r]) {
        ans += a[r];
      }
      r++;
    }
    maxx = max(ans, maxx);
    if (!p[l]) {
      ans -= a[l];
    }
    l++;
  }
  printf("%d\n", maxx);
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    if (p[i]) {
      ans += a[i];
    }
  }
  solve();
  return 0;
}
