#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
int fx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int fy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int TLx[] = {0, -1, -1, 0};
int TLy[] = {-1, -1, 0, 0};
int TRx[] = {-1, -1, 0, 0};
int TRy[] = {0, 1, 1, 0};
int BLx[] = {0, 1, 1, 0};
int BLy[] = {-1, -1, 0, 0};
int BRx[] = {0, 1, 1, 0};
int BRy[] = {1, 1, 0, 0};
int n, k, x;
long long sum[200010];
long long a[200010];
long long s[200010];
long long total;
long long res;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x) {
      s[i] = a[i];
      total += a[i];
    }
    s[i] += s[i - 1];
  }
  res = total;
  for (int i = 1; i <= n; i++) {
    if (i >= k) {
      long long p = sum[i] - sum[i - k];
      long long q = s[i] - s[i - k];
      res = max(res, total - q + p);
    }
  }
  cout << res << endl;
  return 0;
}
