#include <bits/stdc++.h>
using namespace std;
long long const M = 1e5 + 10, N = 1e8 + 10, pi = acos(-1);
int n, k, x, ans, cnt;
int a[M], b[M];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i]) ans += a[i];
  }
  for (int i = 0; i < k; i++) {
    if (!b[i]) ans += a[i];
  }
  int mx = ans;
  for (int j = 0, i = k; i < n;) {
    if (!b[j]) ans -= a[j];
    if (!b[i]) ans += a[i];
    mx = max(ans, mx);
    i++;
    j++;
  }
  cout << mx;
}
