#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> a1(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int64_t initSum = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t) {
      a1[i] = 0;
      initSum += a[i];
    } else {
      a1[i] = a[i];
    }
  }
  vector<int> subSums(n, 0);
  subSums[0] = a1[0];
  for (int i = 1; i < n; i++) {
    subSums[i] = subSums[i - 1] + a1[i];
  }
  int64_t max = subSums[k - 1];
  for (int i = k; i < n; i++) {
    int newMax = subSums[i] - subSums[i - k];
    if (max < newMax) {
      max = newMax;
    }
  }
  cout << max + initSum;
}
