#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
int n, k, a[NMAX], b[NMAX];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  int s, smax, sk;
  s = smax = sk = 0;
  for (int i = 1; i <= k; i++) {
    if (b[i] == 1)
      s += a[i];
    else
      sk += a[i];
  }
  smax = max(smax, sk);
  for (int i = k + 1; i <= n; i++) {
    if (b[i] == 1)
      s += a[i];
    else
      sk += a[i];
    if (b[i - k] == 0) sk -= a[i - k];
    smax = max(smax, sk);
  }
  cout << s + smax << "\n";
  return 0;
}
