#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, teo = 0, s = 0, a[100001], t[100001];
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    cin >> t[i];
    if (t[i] == 1) {
      teo = teo + a[i];
      a[i] = 0;
    }
    a[i] = a[i] + a[i - 1];
  }
  for (i = k; i <= n; i++) s = max(s, a[i] - a[i - k]);
  cout << teo + s;
}
