#include <bits/stdc++.h>
using namespace std;
int cnt[100005], ty[100005];
vector<int> a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0, x; i < n; i++) {
    cin >> x, a.push_back(x);
    cnt[i + 1] = cnt[i] + x;
  }
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    ty[i + 1] = ty[i];
    if (x == 1) {
      ty[i + 1] += a[i];
    }
  }
  int maxi = 0;
  for (int i = 1; i <= n; i++) {
    if (i + k - 1 <= n) {
      maxi = max(maxi, ty[n] + cnt[i + k - 1] - cnt[i - 1] -
                           (ty[i + k - 1] - ty[i - 1]));
    }
  }
  cout << maxi << '\n';
  return 0;
}
