#include <bits/stdc++.h>
using namespace std;
long long int GCD(long long int a, long long int b) {
  if (b == 0) return a;
  return GCD(b, fmod(a, b));
}
long long int minimo(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
int main() {
  long long int k, n;
  cin >> n >> k;
  vector<long long int> a, b, ut, t;
  a.push_back(0);
  b.push_back(0);
  for (long long int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    ut.push_back(temp);
  }
  for (long long int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    t.push_back(temp);
  }
  long long int x = 0, y = 0;
  for (long long int i = 0; i < n; i++) {
    x += ut[i];
    if (t[i]) y += ut[i];
    a.push_back(x);
    b.push_back(y);
  }
  long long int ma = 0;
  for (long long int i = k; i <= n; i++) {
    long long int e = b[i - k] + a[i] - a[i - k] + b[n] - b[i];
    if (e > ma) ma = e;
  }
  cout << ma;
}
