#include <bits/stdc++.h>
using namespace std;
int n, k, a[100001], t[100001], jem[100001], res, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    jem[i] = jem[i - 1];
    if (!t[i])
      jem[i] += a[i];
    else
      res += a[i];
  }
  ans = res;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, res + (jem[(i + k - 1 > n ? n : i + k - 1)] - jem[i - 1]));
  }
  cout << ans;
}
