#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    if (b[i] == 1) {
      ans += a[i];
      a[i] = 0;
    }
  long long temp = 0, max = 0;
  for (int i = 0; i < k; ++i) {
    temp += a[i];
  }
  ans += temp;
  max = temp;
  for (int i = 1; i <= n - k; ++i) {
    temp += (a[i + k - 1] - a[i - 1]);
    if (max < temp) {
      ans -= max;
      max = temp;
      ans += max;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}
