#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int tset = 0, kset = 0, set = 0, n, k, a[100000], t[100000],
                sum = 0, ksum[100000] = {0}, x = 0;
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i < n; i++) {
    cin >> t[i];
    if (t[i] == 1) sum += a[i];
  }
  for (long long int i = 0; i < k; i++) {
    if (t[i] == 0) {
      ksum[x] += a[i];
    }
  }
  x++;
  for (long long int i = 1; i <= n - k; i++) {
    set = 0;
    kset = 0;
    tset = 0;
    if (t[i - 1] == 0) {
      ksum[x] = ksum[x - 1] - a[i - 1];
      set = 1;
      tset = 1;
    }
    if (t[k + i - 1] == 0) {
      if (set == 1)
        ksum[x] += a[k + i - 1];
      else
        ksum[x] = ksum[x - 1] + a[k + i - 1];
      kset = 1;
    }
    if (tset == 0 && kset == 0) ksum[x] = ksum[x - 1];
    x++;
  }
  sort(ksum, ksum + x);
  cout << ksum[x - 1] + sum;
}
