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