#include <bits/stdc++.h>
using namespace std;
void JIZZ() {
  cout << "";
  exit(0);
}
const long double PI = 3.14159265358979323846264338327950288;
const long double eps = 1e-13;
const long long mod = 1e9 + 7;
int a[200005], pre[200005];
;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      ans += a[i];
      a[i] = 0;
    }
  }
  int mx = ans;
  pre[0] = a[0];
  for (int i = 1; i < 200005; ++i) pre[i] = pre[i - 1] + a[i];
  for (int i = 0; i < n; ++i) {
    mx = max(mx, ans + pre[i + k - 1] - (i ? pre[i - 1] : 0));
  }
  cout << mx;
}
