#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, a[100001], behave[100001], x = 0, y = 0, ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int j = 1; j <= n; ++j) {
    cin >> behave[j];
    if (behave[j] == 1) {
      ans += a[j];
      a[j] = 0;
    }
  }
  for (int i = 1; i <= k; ++i) x += a[i];
  y = max(y, x);
  for (int i = k + 1; i <= n; ++i) {
    x -= a[i - k];
    x += a[i];
    y = max(y, x);
  }
  cout << ans + y;
  return 0;
}
