#include <bits/stdc++.h>
using namespace std;
long long pre[100005], a[100005], t[100005];
int main() {
  int n, k;
  long long ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> t[i];
    ans += a[i] * t[i];
    pre[i] = pre[i - 1];
    if (t[i] == 0) pre[i] += a[i];
  }
  long long maxm = 0;
  for (int i = n; i >= k; --i) {
    maxm = max(pre[i] - pre[i - k], maxm);
  }
  cout << ans + maxm << endl;
}
