#include <bits/stdc++.h>
using namespace std;
const long long int lmt = 1e9 + 7;
bool flag;
int main() {
  long long int n, k, ans, c;
  cin >> n >> k;
  long long int a[n], t[n];
  ans = 0;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) {
    cin >> t[i];
    if (t[i] == 1) {
      ans += a[i];
      a[i] = 0;
    }
  }
  for (long long int i = 1; i < n; i++) a[i] = a[i] + a[i - 1];
  c = a[k - 1];
  for (long long int i = 1; i < n - k + 1; i++) {
    if (c < a[i + k - 1] - a[i - 1]) c = a[i + k - 1] - a[i - 1];
  }
  cout << ans + c << endl;
}
