#include <bits/stdc++.h>
using namespace std;
const int oo = 999999999;
const double PI = 3.1415931;
const double eps = 1e-9;
int a[100000 + 10], mark[100000 + 10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int allSum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cin >> mark[i];
    if (mark[i]) allSum += a[i];
  }
  int slept = 0;
  for (int i = 1; i <= k; i++) {
    if (!mark[i]) slept += a[i];
  }
  int ans = allSum + slept;
  for (int i = k + 1; i <= n; i++) {
    if (!mark[i - k]) slept -= a[i - k];
    if (!mark[i]) slept += a[i];
    ans = max(ans, allSum + slept);
  }
  cout << ans << endl;
  return 0;
}
