#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
  long long n, k, a[100005] = {}, t[100005] = {}, cnt = 0, sum = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  for (int i = 1; i <= n; i++) {
    if (t[i]) {
      cnt += a[i];
      a[i] = 0;
    }
  }
  for (int i = 2; i <= n; i++) {
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= n - k + 1; i++) {
    sum = max(sum, a[i + k - 1] - a[i - 1]);
  }
  cout << sum + cnt << endl;
}
