#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 1;
const long long nol = 0;
long long n, k, a, cnt, ans, j, mx;
deque<long long> v, vc;
void vkoshp() {
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  for (long long i = 0; i < n; i++) {
    cin >> a;
    if (a == 1)
      cnt += v[i], vc.push_back(0);
    else
      ans += v[i], vc.push_back(v[i]);
    mx = max(mx, ans);
    if (vc.size() == k) {
      ans -= vc[0];
      vc.pop_front();
    }
  }
  cout << cnt + mx << endl;
}
int main() {
  cout.tie(NULL);
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  long long t = 1;
  while (t--) vkoshp();
}
