#include <bits/stdc++.h>
using namespace std;
int a[200005], t[200005], cur, ans;
int main() {
  int n, k;
  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 <= k; i++)
    if (!t[i]) cur += a[i];
  ans = cur;
  int j = 1, ind = k;
  for (int i = k + 1; i <= n; i++) {
    if (!t[j]) cur -= a[j];
    if (!t[i]) cur += a[i];
    if (ans < cur) {
      ans = cur;
      ind = i;
    }
    j++;
  }
  for (int i = 1; i <= n; i++) {
    if (t[i]) ans += a[i];
  }
  cout << ans << endl;
  return 0;
}
