#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> mi(n);
  for (int &v : mi) cin >> v;
  vector<int> used(n);
  for (int &v : used) cin >> v;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (used[i]) ans += mi[i];
  }
  long long best = 0, now;
  for (int i = 0; i < k; i++) {
    if (!used[i]) best += mi[i];
  }
  now = best;
  for (int i = k; i < n; i++) {
    if (!used[i - k]) now -= mi[i - k];
    if (!used[i]) now += mi[i];
    if (now > best) {
      best = now;
    }
  }
  cout << ans + best;
}
