#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, l, mx = 0, m, i, j, s = 0;
  cin >> n >> k;
  long long int a[n], t[n], sum[n], dv[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
    dv[i] = s;
  }
  s = 0;
  for (i = 0; i < n; i++) {
    cin >> t[i];
    if (t[i] == 1) s += a[i];
    sum[i] = s;
  }
  l = n - k + 1;
  for (i = 0; i < l; i++) {
    m = 0;
    if (i > 0)
      m += dv[i + k - 1] - dv[i - 1];
    else
      m += dv[i + k - 1];
    if (i > 0) m += sum[i - 1];
    m += sum[n - 1] - sum[i + k - 1];
    if (m > mx) mx = m;
  }
  cout << mx << endl;
  return 0;
}
